+ Reply to Thread
Results 1 to 4 of 4

Vba errors 400 and 1004

  1. #1
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    24

    Vba errors 400 and 1004

    Hi,

    Grateful if anyone can help.

    I have a worksheet called "Front" which contains a bunch of named ranges and a couple of macro buttons.

    Behind it is a sheet called "List" which contains an autofiltered table.

    One of the macros on "Front" is to reset the options and clear the autofilter on "List". Code below. It sometimes works. Sometimes I get an error that just says "400". Sometimes, if I run it from the VBA window, I get a runtime 1004 error.

    What am I doing wrong?

    Thanks,

    HE.


    Please Login or Register  to view this content.
    Last edited by headexperiment; 06-13-2011 at 07:37 AM. Reason: add code tags for newbie pm rule

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Vba errors 400 and 1004

    try this:
    Please Login or Register  to view this content.
    because the line that you already have generates an error if there is no filter in the worksheet

  3. #3
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,255

    Re: Vba errors 400 and 1004

    Hi,

    If you try to show all data when either

    (1) There isn't an autofilter object or
    (2) The autofilter object isn't actively filtering anything

    Then you'll get a runtime error. Other things may interfere too - such as worksheet protection.

    You are using XL 2003 so I would do it like this:
    Please Login or Register  to view this content.


    @ mohd9876
    Unfortunately, in XL 2003 the Autofilter object does not have a ShowAllData method, so headexperiment won't be able to check your suggestion.
    Last edited by Colin Legg; 06-13-2011 at 06:45 AM. Reason: comment re 2003 ShowAllData
    Hope that helps,

    Colin

    RAD Excel Blog

  4. #4
    Registered User
    Join Date
    06-13-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Vba errors 400 and 1004

    Thanks Colin. That did the trick

+ 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