I've almost done a macro which helps me delete unnecessary rows from a worksheet, the problem is that it takes around 10 min. when I run it since I looking for 4,000 records and filter them so I will only have around 500 records.
This is the code I've been using now:
Dim RuleCode As Range, i As Long
Set RuleCode = Worksheets("Line").Range("D5", Range("D5").End(xlDown))
For i = RuleCode.Count To 1 Step -1
Select Case RuleCode.Cells(i)
Case "AD001", "AD002", "AD010", "AD015", "AD031", "AD005", "AD035", "AD100", "AD107", "AD108", "AD152", "AD173", "CO017", "CO081", "CO102", "CO035", "CO169", _
"CR003", "CR032", "CR070", "GE006", "GE010", "GE012", "GE028", "GE033", "GE035", "GE038", "GE039", "GE040", "GE041", "GE048", "GE066", "GE067", _
"GE069", "GE073", "GE074", "GE085", "GE092", "GE097", "GE116", "NA023", "NA056", "NA059", "NA061", "NA020", "NA040", "NA055", "NA063", "NA090", _
"NA101", "NA131", "NA135", "NA192", "NA197", "NA198", "NA209", "NA016", "NA042", "NA044", "NA048", "NA065", "NA123", "NA130", "NA174", "NA280", _
"NA291", "PO358"
Case Else
RuleCode.Cells(i).EntireRow.Delete
End Select
Next i
This code helps me, but as I said, it takes around 10 min. to finish, so I've trying another method. All those codes are in a list in another Worksheet but I don't know how to do the same referencing that list. This is what I was trying:
Dim RuleRange As Range
Set RuleRange = Worksheets("List").Range("C2:C68")
Dim RuleCode As Range, i As Long
Set RuleCode = Worksheets("Line").Range("D5", Range("D5").End(xlDown))
For i = RuleCode.Count To 1 Step -1
If RuleCode Is Not RuleRange Then
RuleCode.Cells(i).EntireRow.Delete
End If
Next i
Thank you very much in advance
UPDATE 1:
This is how my sheet looks like. The Table is a table (Object).
When I click the button, the macro runs