Delete Zero 0 and shift the cells up

Abhishekghorpade

Board Regular
Joined
Oct 3, 2018
Messages
78
Hi,

Could you please give me a macro to delete the cell which has only "0" and shift the cells up..

Thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I think we are going to need more information.
What does your data structure look like?
What range are we checking for zeroes?
Do you want to shifts all cells (rows) up, or just that one column?
Does using filters to filter out the zeroes do what you want?
 
Upvote 0
The data is in column C. all the numbers are 6 digits there are few cell where the value is "0" I want those cells to delete and move the cells up

I think we are going to need more information.
What does your data structure look like?
What range are we checking for zeroes?
Do you want to shifts all cells (rows) up, or just that one column?
Does using filters to filter out the zeroes do what you want?
 
Upvote 0
So, just to confirm, you want the data in column C to move up, but you do not want any of the other columns to move up along with it?
 
Upvote 0
OK, if you really do not want the other columns to move up to, try this code:
Code:
Sub MyDeleteMacro()

'   Replace all zeroes in column C with blanks
    Columns("C:C").Replace What:="0", Replacement:="", LookAt:=xlWhole, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
'   Delete all blank cells and shift cells up
    Columns("C:C").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
    
End Sub
 
Upvote 0
Thats exactly what i wanted.. Thank you so much
OK, if you really do not want the other columns to move up to, try this code:
Code:
Sub MyDeleteMacro()

'   Replace all zeroes in column C with blanks
    Columns("C:C").Replace What:="0", Replacement:="", LookAt:=xlWhole, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
'   Delete all blank cells and shift cells up
    Columns("C:C").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
    
End Sub
 
Upvote 0
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top