Consulting

Results 1 to 3 of 3

Thread: VBA to autofilter with Array

  1. #1

    VBA to autofilter with Array

    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.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Did you try xlAnd?

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

  3. #3
    Hi Kenneth,

    It filters, but doesn't select anything.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •