Results 1 to 6 of 6

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

Threaded View

  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:

        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight
        Columns("C:C").Select
        Selection.Insert Shift:=xlToRight
        Range("B2").Select
        Sheets("MASTER").Select
        Columns("B:B").Select
        Selection.Copy
        Sheets("Firm Func.").Select
        Columns("C:C").Select
        ActiveSheet.Paste
        Sheets("MASTER").Select
        Columns("I:I").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Firm Func.").Select
        Columns("D:D").Select
        ActiveSheet.Paste
        Range("B2").Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "=IF(RC[2]>"""",RC[2],RC[1])"
        Range("B2").Select
        Selection.Copy
        Range("B3").Select
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Paste
        Columns("B:B").Select
        Application.CutCopyMode = False
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Columns("C:C").Select
        Application.CutCopyMode = False
        Selection.Delete Shift:=xlToLeft
        Columns("C:C").Select
        Selection.Delete Shift:=xlToLeft
        Columns("B:B").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
    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

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