Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hi Gang,
Wanted to see if anyone has a way of speeding up a working code. Currently it takes 3-5min on my PC to run this code. Was hoping for a more time efficient update to make this faster, any suggestions are appreciated.
What it does: Looks at column B on my worksheet and finds any cells with the value 0 and deletes the entire row. It starts by passing the headers and looking at my data range from (B7:Bxxxx). For my test the data went from B7:B9007 and expands from column A:J.
Here is the working code:
Wanted to see if anyone has a way of speeding up a working code. Currently it takes 3-5min on my PC to run this code. Was hoping for a more time efficient update to make this faster, any suggestions are appreciated.
What it does: Looks at column B on my worksheet and finds any cells with the value 0 and deletes the entire row. It starts by passing the headers and looking at my data range from (B7:Bxxxx). For my test the data went from B7:B9007 and expands from column A:J.
Here is the working code:
Code:
Sub DeleteRows()
Dim r As Long
Dim FirstRow As Long
Dim LastRow As Long
'Need to avoid the top header rows
FirstRow = 7
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For r = LastRow To FirstRow Step -1
If Cells(r, "B") = 0 And Cells(r, "B") = 0 Then
Rows(r).Delete
End If
Next r
End Sub
Last edited: