0
votes

I'm trying to filter a sheet by the name "RA" appearing in the second column. I've constructed the following code but it seems there is a compile error: Expected: Expression after I click enter on the line "Field:= ....". Is this the correct syntax for what I am trying to achieve? Thanks.

With CurrentSheet
    Set LastAddressCurrent = .Cells(.Rows.Count, "A").End(xlUp)
    LastRowCurrent = LastAddressCurrent.Row
    .Range(.Cells(1, 2), .Cells(LastAddressCurrent, LastRowCurrent)).AutoFilter
        Field:= 2, Criteria1:= "RA"
    End If
End With
1
.Range(.Cells(1, 2), .Cells(LastAddressCurrent, LastRowCurrent)).AutoFilter Field:= 2, Criteria1:= "RA" this should come in a single line. - Mrig
or write ....)).AutoFilter _ and then in next line write Field:= 2, Criteria1:= "RA" - Mrig
Also, there is End If but I don't see If... - Mrig
Yeah that wasn't meant to be there. I previously had an if statement but it deleted it. It works now. Thank you - Liz

1 Answers

0
votes

You need a code line continuation _