Help with Autofilter with two criteria

  • Thread starter Thread starter Randy Reese
  • Start date Start date
R

Randy Reese

HELP!!!!
I am trying to keep every row that has Str in column B and "a" in column A.

Sub Copy_With_AutoFilter2(WS As Worksheet, WS2 As Worksheet, Str As String,
LRow As Long)



With WS.Columns("a:a")
.AutoFilter Field:=2, Criteria1:=Str, Operator:=xlAnd, Field:=1,
Criteria2:="a"
WS.Range("D:F").Cells.SpecialCells(xlCellTypeVisible).Copy _
WS2.Range("B" & LRow)
End With

WS.AutoFilterMode = False

End Sub
 
Hi
try replacing the line
With WS.Columns("a:a")
.AutoFilter Field:=2, Criteria1:=Str, Operator:=xlAnd,
Field:=1,
Criteria2:="a"

with
With WS.Columns("a:a")
.AutoFilter Field:=2, Criteria1:=Str, Operator:=xlAnd
.autofilter Field:=1, Criteria1:="a"
 
Back
Top