VBA Counting Number of AutoFilter Columns

AliCat

Board Regular
Joined
Aug 8, 2002
Messages
82
Is there a way in VBA to count the number of columns holding the filter symbol?
I currently have a Reset macro to remove all filters in one go:
Code:
Selection.AutoFilter Field:= i
and cycle through this a fixed number of times. Some of my sheets may only have 4 columns filtered and some could have as much as 18 (although the're not all aplied at once).
It would be helpful to know one way or the other if this is possible.
Thanks in advance.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If you just want to remove the filter altogether, you can use:
Code:
Sub ClearFilters()
   With ActiveSheet
      If .AutoFilterMode Then .AutoFilter.Range(1).AutoFilter
   End With
End Sub
or if you simply want to stop filtering, but leave the autofilter set up, you can use:
Code:
Sub ShowAll()
   With ActiveSheet
      If .FilterMode Then .ShowAllData
   End With
End Sub
HTH
 
Upvote 0
Your method 2 suits just fine I just want to remove multiple filters in one go so that I can start again and was aware that I was looping through filters that might not exist.
Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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