Advanced Filter doesn't work

1k Views Asked by At

Why doesn't this code work? Col "A" is populated with either FALSE or TRUE. b2 contains FILTER b3 contains TRUE

Sub FAST_hide_rows()
Range("a1:a153804").AdvancedFilter Action:=xlFilterInPlace,CriteriaRange:=Range("b2:b3"), Unique:=False
End Sub

The code finds all of the records but does not hide them. It should be hiding all of the FALSE rows. It works on one sheet but not on another.

Any ideas?

1

There are 1 best solutions below

2
On BEST ANSWER

It works on one sheet but not on another.

You need to tell the macro which workhseet it should work with other wise it will work on the ActiveSheet.

Try this:

Sub FAST_hide_rows()
Dim WS As Worksheet
Set WS = Sheet1      'Change it with your sheet number

WS.Range("a1:a153804").AdvancedFilter Action:=xlFilterInPlace,CriteriaRange:=WS.Range("b2:b3"), Unique:=False

End Sub