How to Get rid of all filters in an excel worksheet

aryaden

Board Regular
Joined
Jun 9, 2021
Messages
101
Office Version
  1. 2019
Platform
  1. Windows
I am currently applying macros to multiple worksheets, some of them have filters rows and tables. Is there any way to completely get rid of filter rows and tables and just leave the data with formatting (colors, font, cell size...). I wanted to incorporate it into the beginning of my macro code

Thanks for all the help!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You did not say if the filters are Auto or Advanced.
One of these two methods should do what you need:

Rich (BB code):
ActiveSheet.AutoFilterMode = False

or

Rich (BB code):
On Error Resume Next
ActiveSheet.ShowAllData
Err.Clear

You do not need to be on the sheet at the time of execution, so if that is the case, substitute ActiveSheet for the worksheet's tab name or CodeName that the code should apply to.
 
Upvote 0
Solution
You did not say if the filters are Auto or Advanced.
One of these two methods should do what you need:

Rich (BB code):
ActiveSheet.AutoFilterMode = False

or

Rich (BB code):
On Error Resume Next
ActiveSheet.ShowAllData
Err.Clear

You do not need to be on the sheet at the time of execution, so if that is the case, substitute ActiveSheet for the worksheet's tab name or CodeName that the code should apply to.
Thanks for the input!

Currently I am using "Selection.Autofilter" to remove the filter rows. I don't think I explained well in my last post but I am not trying to clear the filters but get rid of them all together while keeping the content in the cells. Is there anyway to do this?

Best,
Arya
 
Upvote 0
Actually your first post made more sense than your second post.

This you wrote makes no sense:
"I am using "Selection.Autofilter" to remove the filter rows."
Rows are not "removed" if they are filtered.

This you wrote makes no sense:
"I am not trying to clear the filters but get rid of them all together while keeping the content in the cells."
Content never leaves any cells when filtering data. And you "get rid of them [filters]" altogether with the code I posted.
 
Upvote 0
Actually your first post made more sense than your second post.

This you wrote makes no sense:
"I am using "Selection.Autofilter" to remove the filter rows."
Rows are not "removed" if they are filtered.

This you wrote makes no sense:
"I am not trying to clear the filters but get rid of them all together while keeping the content in the cells."
Content never leaves any cells when filtering data. And you "get rid of them [filters]" altogether with the code I posted.
Sorry for not explaining it well. I tried to make an example to better showcase what I mean, but the filter rows do not show up when I use the Add-In to paste example Excel Sheets so I included a screenshot.

When I try your methods, the cells still have the filter option dropdown on them even though it clears the filter choices made.

Example Starting Sheet:
ExampleFilter.png


I want to change this so that row 2 no longer has the filter drop downs, and instead looks like this:

Example Output:
Book1345.xlsm
ABCDEFGH
1FirstLast12345
2aabbccddee
3AliBrownX
4BillPatelXX
5CatherineGomezXX
6DelilahHarringtonX
7Eva LeeXXXX
8FreyaMillerXXX
9GinaWilliamsXXX
10HerrodSmithXXX
11IsabelleCooperX
12JohnWakefieldXXX
13
Sheet5


Sorry for the hassle and I appreciate your patience.
Best,
Arya
 
Last edited:
Upvote 0
So it is AutoFilter.

This line I posted does what you say you want, which is to remove (not show) the drop down filter arrows, and it releases the filter action altogether.
ActiveSheet.AutoFilterMode = False

Two things I am still not clear about:

(1)
When you execute that code, are you expecting the filter to stay in place, meaning some rows will not be visible because they are, well, filtered. If the answer to that is no, then that code line is all you need. If the answer is yes, you need extra code to keep the filter in place but to not show the drop-down arrows. I would be cautious about that if I were you, because your users might not understand why rows are not visible because the familiar-looking drop down arrows are not visible.

(2)
You first wrote:
"I am currently applying macros to multiple worksheets..."
Maybe you are not executing this code such that it is pointing to each worksheet in your (presumably though you did not say) loop macro, and maybe the code I posted does what you want but your code, which you did not bother to post so we are all in the dark about that, is not referring to its respective parent worksheet in the loop, just the active sheet at the time of macro execution.

And further to that, you do not need to actually select an in-loop worksheet to refer to it in your code, but again, without seeing your code it's anyone's guess what you are doing, and how, and why.
 
Upvote 0
So it is AutoFilter.

This line I posted does what you say you want, which is to remove (not show) the drop down filter arrows, and it releases the filter action altogether.
ActiveSheet.AutoFilterMode = False

Two things I am still not clear about:

(1)
When you execute that code, are you expecting the filter to stay in place, meaning some rows will not be visible because they are, well, filtered. If the answer to that is no, then that code line is all you need. If the answer is yes, you need extra code to keep the filter in place but to not show the drop-down arrows. I would be cautious about that if I were you, because your users might not understand why rows are not visible because the familiar-looking drop down arrows are not visible.

(2)
You first wrote:
"I am currently applying macros to multiple worksheets..."
Maybe you are not executing this code such that it is pointing to each worksheet in your (presumably though you did not say) loop macro, and maybe the code I posted does what you want but your code, which you did not bother to post so we are all in the dark about that, is not referring to its respective parent worksheet in the loop, just the active sheet at the time of macro execution.

And further to that, you do not need to actually select an in-loop worksheet to refer to it in your code, but again, without seeing your code it's anyone's guess what you are doing, and how, and why.
Thank you, I figured out that my issues were due to my data being in a table and the code you sent did not work for a table. Once I converted it to a range it worked. Thank you for all the help!
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,697
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top