Maria Clara
New Member
Hello All again,
I'm having trouble in trying to write some for next loops. I have an spreadsheet with 9 columns and on the 8th column I have some rows that are with value 0 which I need to remove the entire Row.
When I run the Macro below it does not remove all rows and I have to run it twice to do the job.
Could you pls check my code? Thank you!
File attached: http://www.sendspace.com/file/h44kdp
**In this file for eg. I have 10 rows with 0 value, I run the macro and It removes only 9 rows. After that I need to run it again to remove the last row.
Dim i As Integer
Dim LastRow As Long
Range("A1").Select
LastRow = Worksheets("Plan1").Cells(Rows.Count, 1).End(xlUp).Row - 1
Worksheets("Plan1").Activate
For i = 1 To LastRow
If Cells(i + 1, 8).Value = 0 Then Cells(i + 1, 8).EntireRow.Delete
Next i
End Sub
I'm having trouble in trying to write some for next loops. I have an spreadsheet with 9 columns and on the 8th column I have some rows that are with value 0 which I need to remove the entire Row.
When I run the Macro below it does not remove all rows and I have to run it twice to do the job.
Could you pls check my code? Thank you!
File attached: http://www.sendspace.com/file/h44kdp
**In this file for eg. I have 10 rows with 0 value, I run the macro and It removes only 9 rows. After that I need to run it again to remove the last row.
Dim i As Integer
Dim LastRow As Long
Range("A1").Select
LastRow = Worksheets("Plan1").Cells(Rows.Count, 1).End(xlUp).Row - 1
Worksheets("Plan1").Activate
For i = 1 To LastRow
If Cells(i + 1, 8).Value = 0 Then Cells(i + 1, 8).EntireRow.Delete
Next i
End Sub