+ Reply to Thread
Results 1 to 4 of 4

Detect autofilter status

  1. #1
    Rob T
    Guest

    Detect autofilter status

    I have a spreadsheet which has autofilter on. I have a macro which selects certains areas (using autofilter) and copies them to another sheet.

    The trouble arises if some filters are left on but users, then obviously it just adds more filters and copies what's left across. I have a simple loop which goes through and sets all the filters to show all. The trouble is that this loop takes forever to run and that particular loop runs twice. With that loop in place the macro takes just over 5 minutes to run, if I comment it out the rest of the code takes 15 seconds to run.

    Is there any way to detect what the autofilter status is for a column and then only change its state if it's set to filter?

    Any help would be appreciated.

    Cheers,

    Rob

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe you could turn it off before you run the macro

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Rob T
    Guest
    Thank-you. I don't know why I didn't think of that

    That cut the run-time down from 5 minutes to 22 seconds!!!

    Cheers,

    Rob

  4. #4
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi Rob

    You can check for applied filters without removing autofilter altogether:

    Please Login or Register  to view this content.
    which will check first if a filter has been applied and then remove it if it has (removes all filters, across all columns).

    Since filtering triggers recalculation, you may find your macro's speed can be improved by using

    Please Login or Register  to view this content.
    Hope this helps!

    Richard

+ 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