+ Reply to Thread
Results 1 to 6 of 6

Run-time error 1004 when running Advanced Filter for Unique Values in macro

  1. #1
    Registered User
    Join Date
    10-16-2012
    Location
    Milwaukee, Wisconsin
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    9

    Run-time error 1004 when running Advanced Filter for Unique Values in macro

    I have recorded a series of macros that involve using the Advanced Filter to filter columns for unique values. The macros have worked perfectly in Excel 2003, but when I try to use them in Excel 2007 or 2010 I'm receiving the following error message: "Run-time error '1004': AdvancedFilter method of Range class failed". The funny thing is, the macro will run but stall once it reaches the AdvancedFilter code (which is the last line of code). If I hit ESC to stop the macro, Excel shows a filtered list as if the macro had run correctly, but returns the error above. I've let the macro run for 20 minutes to see if it's a time issue and it will continue to stall on the AdvancedFilter code indefinitely. Note, in order to go from running the macros in 2003 to 2007/2010 I've changed all references of 65,536 rows to 1,048,576 rows within the code. Here's the code for one of the macros where this is occurring:

    Please Login or Register  to view this content.
    Is there some change that needs to be made in order for this to work in Excel 2007/2010?
    Last edited by jacobadger; 10-16-2012 at 11:36 AM. Reason: clarification

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run-time error 1004 when running Advanced Filter for Unique Values in macro

    The problem could be because you are filtering an entire column.

    Can't you set the range to filter to only cover the data in that column?

  3. #3
    Registered User
    Join Date
    10-16-2012
    Location
    Milwaukee, Wisconsin
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    9

    Re: Run-time error 1004 when running Advanced Filter for Unique Values in macro

    I have tried that and specifying a specific range (ex. B2:B250000), both return the same situation as described above: they stall indefinitely on that last line of code, but if I hit ESC Excel shows a filtered list and the 1004 Run-time error.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run-time error 1004 when running Advanced Filter for Unique Values in macro

    Does your data extend down to row 250000?

    Does this work?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-16-2012
    Location
    Milwaukee, Wisconsin
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    9

    Re: Run-time error 1004 when running Advanced Filter for Unique Values in macro

    Yes, it works. Thanks a million!

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run-time error 1004 when running Advanced Filter for Unique Values in macro

    @ jacobadger

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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