+ Reply to Thread
Results 1 to 8 of 8

Autofilter using array as criteria = Run time error

  1. #1
    Registered User
    Join Date
    05-18-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Autofilter using array as criteria = Run time error

    Hi, I have one master file where I need to split out and send data to 15 different regions. I've tried to make a macro to automate it by using autofilter and copy to achieve it but I keep getting a Run time Error 1004. I am using Excel 2007, my code below though I cut out the values for the string array. If I step into the code, the error pops up when I get to the filter by criteria line.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Autofilter using array as criteria = Run time error

    It should be Criteria1 rather than Criteria
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    05-18-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Autofilter using array as criteria = Run time error

    Oh pure genius! Now I get run time error 438 when it tries to paste!

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Autofilter using array as criteria = Run time error

    Replace the .sheet1 with .sheets(1)

  5. #5
    Registered User
    Join Date
    05-18-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Autofilter using array as criteria = Run time error

    Now I get the 1004 error again. Does it have anything to do with ws being set to workbook.add instead of workbook?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Autofilter using array as criteria = Run time error

    Which line is giving the error?

  7. #7
    Registered User
    Join Date
    05-18-2011
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Autofilter using array as criteria = Run time error

    .sheets(1).Paste

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Autofilter using array as criteria = Run time error

    Please Login or Register  to view this content.



+ 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