browncountry
New Member
- Joined
- Feb 2, 2019
- Messages
- 13
The code below works as is, but when I there are 40,000 to 50,000 lines of data, it tends to slow down a lot. In the code below, I'm checking for unwanted data in columns A and G. Is there anything I can do to speed this process up? Thanks!
VBA Code:
Sub DeleteEntireRow()
Dim RowToTest As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
For RowToTest = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
With Cells(RowToTest, 1)
If .Value = "GRAND TOTAL" _
Then _
Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
For RowToTest = Cells(Rows.Count, 7).End(xlUp).Row To 2 Step -1
With Cells(RowToTest, 7)
If .Value <> "P" _
Then _
Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub