+ Reply to Thread
Results 1 to 8 of 8

VBA Autofilter call not working

  1. #1
    Registered User
    Join Date
    11-14-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA Autofilter call not working

    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?
    Last edited by sflowers; 11-14-2011 at 07:56 PM. Reason: Syntax

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: VBA Autofilter call not working

    Hi sflowers and welcome to the forum,

    Turn on the macro recorder and do the steps you want to happen.

    Look at the VBA code to see what it did. The recorded code and what you have should show you the way.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    11-14-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Autofilter call not working

    did that, does not work, in fact I can remove the filter and run the just written code and nothing happens

  4. #4
    Registered User
    Join Date
    11-14-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Autofilter call not working

    So for an overview, I just recorded the following with the autorecord 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?

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: VBA Autofilter call not working

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this

    and

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: VBA Autofilter call not working

    I guess I need a sample file to see what I'm missing in this question.

    You can attach a sample by clicking on "Go Advanced" and then the Paper Clip Icon.

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: VBA Autofilter call not working

    For reference cross posted (also without tags) here
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  8. #8
    Registered User
    Join Date
    11-14-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Autofilter call not working

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1