Programmatically Work with Autofilters

J

JJ

Is there a way to programmatically determine if an Autofilter has been
implemented by the user.

If so, is there a way to turn it off, perform other tasks, and then re-
implement the autofilter or possibly turn it into an actual filter?

What I would like to do is perform some tasks based on what is
visible, whether the Project file has been filtered via a filter or an
autofilter. When a filter is on, that is pretty easy to determine,
turn off, and re-implement. Autofilters... not so much... so I think.

Any help would be appreciated!

Thank you!
JJ
 
J

John

JJ said:
Is there a way to programmatically determine if an Autofilter has been
implemented by the user.

If so, is there a way to turn it off, perform other tasks, and then re-
implement the autofilter or possibly turn it into an actual filter?

What I would like to do is perform some tasks based on what is
visible, whether the Project file has been filtered via a filter or an
autofilter. When a filter is on, that is pretty easy to determine,
turn off, and re-implement. Autofilters... not so much... so I think.

Any help would be appreciated!

Thank you!
JJ

JJ,
Unfortunately there is no way to directly determine if a user has
activated an autofilter. The AutoFIlter Method can tell you if the auto
filter feature is activated or not but it won't tell you if a filter is
applied.

However when a direct method isn't available, you can often find an
indirect way to get what you need. In your case this is what I would
probably do. Unless the file is sorted you can tell if it is filtered by
looking at the task ID sequence. If everything is consecutive, you know
it isn't filtered. But, let's say the user has applied an autofilter.
Use a spare flag field and set it to true for all tasks in the active
view. Next, apply the "all tasks" filter and do whatever processing you
need to do. Then use the FilterEdit Method to create a new filter,
(actual filter as you call it), that filters on the flag field. You have
indirectly detected a user applied autofilter, removed it for processing
and then created a normal filter that emulates the autofilter that was
applied. Of course you won't know the criteria the user used to set the
autofilter so your new normal filter may not truly replicate the intent
of the original autofilter.

Hope this helps.

John
Project MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top