Consulting

Results 1 to 3 of 3

Thread: VBA Autofilter call does not work

  1. #1
    VBAX Newbie
    Joined
    Nov 2011
    Posts
    2
    Location

    VBA Autofilter call does not work

    I am having the most ridiculous problem, but I cannot get a VBA autofilter call to work to save my life! I can manually execute the filter in question, but when I run the following

    Sub LocationFilter()
    MsgBox (ActiveSheet.Name)
    ActiveSheet.Range("A:M").AutoFilter Field:=2, Criteria1:="802"
    End Sub
    absolutely nothing happens. Sheet is unprotected, data format is general......Any suggestions?

    So for an overview, I just recorded the following with the auto record feature

    Sub Macro2()
    ' Macro2 Macro
    ActiveSheet.Range("$A$1:$O$136267").AutoFilter Field:=4, Criteria1:="7"
    End Sub
    I then cleared the filter on the sheet and re-executed the macro, nothing happened. WTF?
    Last edited by Aussiebear; 03-21-2023 at 03:48 PM. Reason: Added code tags to supplied code

  2. #2
    For reference - cross posted (also without tags) here

  3. #3
    VBAX Newbie
    Joined
    Nov 2011
    Posts
    2
    Location
    For any future users, I was missing a line of code in order to engage the filter (when I recorded macro filter was already in place)

    >>Selection.Autofilter

Posting Permissions

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