Hi,
I have the following code to delete an entire row if it contains in the this example string "Mr Smith".
I loop over 100k rows and the macro run super slow.
Is there a way to code it to do the same but result in running the macro much quicker?
thank you
I have the following code to delete an entire row if it contains in the this example string "Mr Smith".
I loop over 100k rows and the macro run super slow.
Is there a way to code it to do the same but result in running the macro much quicker?
thank you
VBA Code:
Sub deleteRow(ByVal sht_Name As String)
finalRow = Worksheets(sht_Name).Cells(Sheets(sht_Name).Rows.Count, "a").End(xlUp).Row
For i = finalRow To 1 Step -1
If Worksheets(sht_Name).Range("P" & i).Value <> "Mr Smith" Then
Worksheets(sht_Name).Rows(i).EntireRow.Delete
End If
Next i
End Sub