+ Reply to Thread
Results 1 to 3 of 3

Autofilter Macro Failing because object variable not set

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Autofilter Macro Failing because object variable not set

    Hello, I am trying to sort and unsort some data using a toggle button. the code for the toggle button calls two macros, AFauditasc and AFAudits. The code for all three is below. the whole operation is failing on the red highlighted lines depending on which macro is being called. If I run them individually the first will work, but the second fails every time. It does not matter which macro I run first as both will fail. what am I doing wrong? The error code I am getting is Run time erro 91: Object variable or With block variable not set. Both Macros were recorded with the macro recorder.

    This macro sorts the data ascending.

    Please Login or Register  to view this content.
    This macro sorts the data descending.

    Please Login or Register  to view this content.
    This is the code for the toggle button. It seems to work fine.

    Please Login or Register  to view this content.
    Last edited by dcgrove; 06-18-2009 at 12:33 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Autofilter Macro Failing because object variable not set

    Your code leaves the autofilter in place when either of the 2 routines runs.
    This means next time a routine is run the Autofilter command actually removes the autofilter which is why the clearing of the sort fails.

    You need to test for the autofilter being present are applying if not.
    Please Login or Register  to view this content.
    Both routines will need the additional code.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-01-2016
    Location
    New Delhi
    MS-Off Ver
    Office 2016
    Posts
    1

    Re: Autofilter Macro Failing because object variable not set

    Hi,

    Please help me with Error 424 in following: -

    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