DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
what would be the most effective way i could filter every column for the same criteria? so far i can think of the below sub i made, but it doesnt seem to be that efficient if multiple columns contain the criteria. If you could help me to understand another method i would greatly appreciate the help.
Code:
Sub test()
Dim p As Long
Dim lastCol As Long
lastCol = Range("A1").SpecialCells(xlCellTypeLastCell).Column
For p = 1 To lastCol
With ActiveSheet.Range("A1")
.AutoFilter Field:=p, Criteria1:="=*Trailer*", Criteria2:="=*Dually*", Operator:=xlOr
On Error GoTo 0
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
AutoFilterMode = False
End With
Next p
End Sub