Forum Discussion
MeloNnadi
Mar 08, 2024Copper Contributor
Microsoft Project VBA code to clear all applied filters
Please I need help with writing a VBA code (Macro) on Microsoft Project that will clear/remove all applied filters in a schedule. Thank you.
MeloNnadi
Mar 09, 2024Copper Contributor
Thanks so much John. I have tried the above code and it works. By column filter i just meant the filter option on column headers. You get to it by clicking on the drop down arrow next to the column header.
John-project
Mar 09, 2024Silver Contributor
MeloNnadi,
You;re welcome and thanks for the feedback.
What you call the "column filter" is actually the auto-filter.
Since your goal is to "clear" a file of any attributes that may be applied, may I suggest you also clear any grouping and sorting. In some of my macros, I save those attributes (view, filter, group, etc.) in variables at the beginning so I can work with an unencumbered file as the macro processes. Then, when the macro finishes doing it's thing, I return the file to it's original state from the saved attribute variables. Of course, none of this is necessary if the macro runs exclusively using background processing (i.e. operates directly on Project's objects independent of how the plan is displayed).
John
You;re welcome and thanks for the feedback.
What you call the "column filter" is actually the auto-filter.
Since your goal is to "clear" a file of any attributes that may be applied, may I suggest you also clear any grouping and sorting. In some of my macros, I save those attributes (view, filter, group, etc.) in variables at the beginning so I can work with an unencumbered file as the macro processes. Then, when the macro finishes doing it's thing, I return the file to it's original state from the saved attribute variables. Of course, none of this is necessary if the macro runs exclusively using background processing (i.e. operates directly on Project's objects independent of how the plan is displayed).
John
- MeloNnadiMar 10, 2024Copper Contributor
John-project that would be very helpful too. If you have a macro that in addition to filters also clears grouping and sorting, could you send please.
Thanks again, I appreciate
- John-projectMar 10, 2024Silver Contributor
Again, record a macro of going through the steps and you will have the code you want.
John