Thursday, 5 September 2013

Visual Basic - loop through all cells and delete any zero cell (shift up)

Visual Basic - loop through all cells and delete any zero cell (shift up)

This seems like it should be a fairly simple task but I can't seem to get
it to work- I just want a simple macro that will loop through all the
cells in my worksheet. If the cell is equal to zero (or blank for kicks),
then just delete it, moving the other cells in the column up one.
I got nowhere trying to do it on the whole document, so I tried to do it
on a single column :
Sub Macro6()
'
' Macro6 Macro
'
' Keyboard Shortcut: Ctrl+q
'
For i = 81 To 1 Step -1
If Range("A" & i) = "0" Then Range("A" & i).Delete
Next i
End Sub
But evidently still getting nowhere... Any help would be very much
appreciated !
Note : I don't want to delete any rows, just the individual cells if they
have value 0

No comments:

Post a Comment