Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This code is working, but I have the feeling its not the best code.
Basically, I have a sheet in which if column D is equal to zero, I want to delete the row and shift the rows up. I want to do this for every row, starting at row three to bypass the headings. Please let me know your thoughts. With objWkb.Worksheets("Sorted Rankings") TotalRows = objWkb.Worksheets("Sorted Rankings").Range("D" & objWkb.Worksheets("Sorted Rankings").Rows.Count).End(xlUp).Row For Row = 3 To TotalRows Step 1 If Row TotalRows Then GoTo EndNow: If .Cells(Row, "D").Value = 0 Then .Rows(Row).EntireRow.Delete ' Delete Shift:=xlUp Row = Row - 1 ' Because we deleted a row and shifted it up, we have to make sure variable Row does not get increased otherwise the next row down from a deleted row will not be evaluated! End If 'Check TotalRows in case a row was deleted TotalRows = objWkb.Worksheets("Sorted Rankings").Range("D" & objWkb.Worksheets("Sorted Rankings").Rows.Count).End(xlUp).Row Next Row EndNow: |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VB Code Is Not Working | Excel Discussion (Misc queries) | |||
Code not working and can't see why | Excel Discussion (Misc queries) | |||
Wht is this Code not Working ? | Excel Programming | |||
Code not working | Excel Programming | |||
Code not working | Excel Programming |