+ Reply to Thread
Results 1 to 5 of 5

Autofilter Object-Defined Error

  1. #1
    Registered User
    Join Date
    03-06-2013
    Location
    Smoketown, PA
    MS-Off Ver
    Excel Professional 2010
    Posts
    13

    Autofilter Object-Defined Error

    Hello,
    I'm having a problem with Autofilter in a macro. When I use recorded code, everything works fine.

    Please Login or Register  to view this content.
    However, when I try to generalize the code so I can use it when there are more rows in the spreadsheet (see below) I get the beloved Error 1004: Application-defined or object-defined error.

    Please Login or Register  to view this content.
    The weird part is I've used the exact same generalized code on another worksheet in the same book and it's perfectly okay.

    What am I missing?

    Thanks!!

  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: Autofilter Object-Defined Error

    jRange already refers to a Range object on the active sheet, so you don't need ActiveSheet.Range(jRange).
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-06-2013
    Location
    Smoketown, PA
    MS-Off Ver
    Excel Professional 2010
    Posts
    13

    Re: Autofilter Object-Defined Error

    Thanks. Now I'm getting a different error though:

    Compile error: Named argument not found.
    That line of code is the problem, and excel is highlighting just this bit:
    Criterial:=

  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: Autofilter Object-Defined Error

    Oops, never noticed that.

    It's Criteria1 not Criterial.

  5. #5
    Registered User
    Join Date
    03-06-2013
    Location
    Smoketown, PA
    MS-Off Ver
    Excel Professional 2010
    Posts
    13

    Re: Autofilter Object-Defined Error

    Of course!
    That one I should have spotted.

    Many thanks.

+ 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