Hi everyone,
I am new here and new to VBA as well. I want to create an auto filter code that will delete rows based on criteria. I need to delete rows of one criteria in one column and then another criteria in a different column. I have the following code that will cover one criteria but I want to add the other criteria. I am trying to delete "DO NOT USE" from one and then "WA-KING" from another column.
Note: I had found this code on another forum but was trying to manipulate to work for me but it has not worked for me. This code may be atrocious
I am new here and new to VBA as well. I want to create an auto filter code that will delete rows based on criteria. I need to delete rows of one criteria in one column and then another criteria in a different column. I have the following code that will cover one criteria but I want to add the other criteria. I am trying to delete "DO NOT USE" from one and then "WA-KING" from another column.
Note: I had found this code on another forum but was trying to manipulate to work for me but it has not worked for me. This code may be atrocious
Code:
' This will be to filter for the 2 Criteria that needs to deleted
Dim ContractNum As String
Dim InvNum As String
Dim FileRng As Range
Dim FileLastRow As Long
Dim File As Range
Dim t As Single
t = Timer
Sheets("GL Sales Tax Amended FY18 Month").Select 'Activate the correct sheet
FileLastRow = ActiveSheet.Range("A2").End(xlUp).Row
'Identify the total range of lined, including the header.
Set FileRng = Sheet1.Range("N2").End(xlUp)
'Using the Autofilter method to elimate "Do not Use" rows
Application.DisplayAlerts = False
With FileRng
.AutoFilter Field:=1, Criteria1:="DO NOT USE"
.Offset(1, 0).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Rows.Delete
End With
Application.DisplayAlerts = True
'Turn off the autofilter safely
With Sheet1
.AutoFilterMode = False
If .FilterMode = True Then
.ShowAllData
End If
End With
MsgBox "Filtered the data 'AutoFilter' strategy completed in " & Timer - t & " seconds."
Last edited by a moderator: