VBA filters using 3 or more criteria

tanyaleblanc

Board Regular
I'm trying to filter using 3 criteria but I'm getting an error, here is the code I tried.

With ActiveSheet
.AutoFilterMode = False
With Range("A2:I2")
.AutoFilter
.AutoFilter field:=4, Criteria1:="Text56", Operator:=xlAnd, Criteria2:="Text76", Operator:=xlAnd, Criteria3:="Text80"
End With
End With
 

Fluff

MrExcel MVP, Moderator
Try
Code:
With ActiveSheet
   .AutoFilterMode = False
   With .Range("A2:I2")
      .AutoFilter 4, Array("Text56", "Text76", "Text80"), xlFilterValues
   End With
End With
 

tanyaleblanc

Board Regular
Works perfect, thank you so much, the purpose of the filter was so that I could delete those lines, but my delete is not working,

Sub Adjust_Report()
Dim lastrow As Long
Dim lRow As Long
Dim Rng As Range
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
Dim fd As Office.FileDialog
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
lRow = ActiveSheet.Range("A500").End(xlUp).Row

If Range("f3:f" & lRow).SpecialCells(xlCellTypeVisible).Count > 1 Then
ActiveSheet.Range("a2:j" & lRow).Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If
 
Last edited:

Fluff

MrExcel MVP, Moderator
How about
Code:
Sub Adjust_Report()
With ActiveSheet
   .AutoFilterMode = False
   With .Range("A2:I2")
      .AutoFilter 4, Array("Text56", "Text76", "Text80"), xlFilterValues
   End With
   .AutoFilter.Range.Offset(1).EntireRow.Delete
   .AutoFilterMode = False
End With
End Sub
 

Some videos you may like

This Week's Hot Topics

Top