Faintkitara
Board Regular
- Joined
- Jun 23, 2016
- Messages
- 59
So I found and manipulated code that Autofilters a specific column by criteria (if name is John) and finally deletes all of the other rows that don't have that name. Seems pretty easy but my code takes an entire 50 seconds to run which is wayyyy to long.
Is there a way to rewrite this code that makes it faster but does the same thing?
Is there a way to rewrite this code that makes it faster but does the same thing?
Code:
Sub FilterandDelete
Dim i As Integer, rngData As Range
Set rngData = Worksheets("Backlog").Range("A4")
i = Application.WorksheetFunction.Match("Leader", Range("A4:JD4"), 0)
rngData.AutoFilter Field:=i, Criteria1:="John"
Dim lRows As Long
Application.Calculation = xlCalculationManual
For lRows = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If Cells(lRows, 1).EntireRow.Hidden = True Then Cells(lRows, 1).EntireRow.Delete
Next lRows
Application.Calculation = xlCalculationAutomatic
End Sub
Last edited: