I would like to clear all filters from table whenever the sheet is changed.
VBA - Clearing Filters
- Jeffrey Smith
- Thread is marked as Resolved.
-
-
-
-
is the (1) for the table?
should I place my table name there
-
Hello,
The number 1 is an index ...
So, since you most probably have One Table in your sheet, there is no obligation to replace the number 1 by the Table's name
Hope this clarifies
-
If you have multiple tables or only one then use
CodePrivate Sub Worksheet_Activate() 'This macro removes any Table filtering in 'order to display all of the data but it does not remove the filter arrows For Each oTbl In Me.ListObjects oTbl.AutoFilter.ShowAllData Next oTbl End Sub
This code is worksheet event code and will run whenever the sheet is activated. For further information on how to use this code read
-
I would like to clear all filters from table whenever the sheet is changed.
Could you clarify ... " whenever the sheet is changed ...." ???
Is it an event ?
-
Could you clarify ... " whenever the sheet is changed ...." ???
Is it an event ?
im sorry now that i read this it isn't very clear. Not a change in the sheet. when another sheet in the workbook is selected.
I.E.- the table that is filtered is in sheet "Parts List" and is the active sheet. Now I click on sheet "Dashboard". when this action takes place I want all the filters on sheet "Parts List" to clear.
-
If you have multiple tables or only one then use
CodePrivate Sub Worksheet_Activate() 'This macro removes any Table filtering in 'order to display all of the data but it does not remove the filter arrows For Each oTbl In Me.ListObjects oTbl.AutoFilter.ShowAllData Next oTbl End Sub
This code is worksheet event code and will run whenever the sheet is activated. For further information on how to use this code read
thank you this is very helpful and works as you explained it. the link also is helpful.
can I have this "oTbl.AutoFilter.ShowAllData" happen when another sheet other than the one with the table in it is activated?
-
im sorry now that i read this it isn't very clear. Not a change in the sheet. when another sheet in the workbook is selected.
I.E.- the table that is filtered is in sheet "Parts List" and is the active sheet. Now I click on sheet "Dashboard". when this action takes place I want all the filters on sheet "Parts List" to clear.
You can try following :
CodePrivate Sub Worksheet_Activate() ' To be placed in the module of Sheet "Dashboard" For Each oTbl In Sheets("Parts List").ListObjects oTbl.AutoFilter.ShowAllData Next oTbl End Sub
Hope this will help
-
Thank you all
I have it working the way I want now. This is what I did.
CodePrivate Sub Worksheet_DeActivate() For Each otbl In Me.ListObjects otbl.AutoFilter.ShowAllData Next otbl End Sub
I just changed it to whenever the sheet is DeActivated the filter will clear. Now no matter what sheet I switch to the filter will clear.
-
Thanks for your Like
-
Thanks for your Like
thanks for the help. you have literally responded to every Thread I have created, and been very helpful
-
Glad to hear you are getting the required assistance from the Forum ...!!!
-
Nicely copied!!!
-
To do this so that it will work on every sheet use the WorkBook Module
-
To do this so that it will work on every sheet use the WorkBook Module
took it to another level there
-
You should really declare oTbl as a ListObject. My example workbook that I took the code snippet from uses oTbl in several procedures and so it is declared separately
-
thank you i was just trying to figure that out.
does this work for pivot slices as well?
-
What do you want to do? Cler the Slicers?
-
What do you want to do? Cler the Slicers?
Yes
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!