PDA

View Full Version : VBA to autofilter with Array



shiva_reshs
09-20-2018, 01:14 AM
Hi,

Why cant i am able to work with below code after applying "not Equal" <> sign? it works when i put = to sign?


Sub TryFilter()
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("A7:Q" & LastRow)

.AutoFilter Field:=11, Criteria1:=Array("<>Allowance Benefit", "<>Fuel Allowance Benefit", "<>House Allowance", "<>3092", "<>3051"), Operator:=xlFilterValues
End With
End With
End Sub

Intention of doing this is to get those value to show up which is different than above 5 if come up in the column.

Kenneth Hobs
09-20-2018, 07:26 AM
Did you try xlAnd?


.AutoFilter Field:=11, Criteria1:=Array("<>Allowance Benefit", "<>Fuel Allowance Benefit", "<>House Allowance", "<>3092", "<>3051"), Operator:=xlAnd

shiva_reshs
09-20-2018, 08:58 PM
Hi Kenneth,

It filters, but doesn't select anything.