Move up a cell in code
Posted by Bill Mahoney on February 15, 2002 2:03 PM
Hello, i am running through a loop where i am looking for the value zero in a cell and if it finds a zero it will delete the line. The problem is that when it deletes the line the cell below it gets the focus and then i am moving to the next cell. So the cell that recieved the focus after the delete is not being tested. How can i move back up one cell so i can test the value? The code i am using to find and delete the row is as follows:
For Each cell In Range("a1" & ":a" & Count)
If cell.Value = 0 Then
Rows(cell.row & ":" & cell.row).Select
Selection.Delete shift:=xlDown
End If
Next cell
count is a variable that is set to the last row number where it finds a populated cell.
Any help would be greatly appreciated.
Regards,
Bill Mahoney
New York, NY