Help with Autofilter with two criteria

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
 
F

Frank Kabel

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top