ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro for clearing autofilter (https://www.excelbanter.com/excel-programming/339832-macro-clearing-autofilter.html)

BorisS

macro for clearing autofilter
 
I'm having a little trouble with part of a macro. Before running what I need
to run, I need to make sure the autofiler is clear (not turned off, just
clear of selections). I have the command
Selection.AutoFilter Field:="X"

in there 20 times for all the columns that are filtered right now. But I
noticed that if it gets to a column which is not part of the filter set and
tries to run this command on that column, it gives an error. Problem is that
I want to ensure that if another column is added to the filter set, that
column, too, is included in the macro set. Is there any way to basically say
"for all filtered columns on this sheet, clear out the filters" (again,
maintaining the filtering capability on all columns that have it, but just
setting the selections to "all" for each).

Thx.
--
Boris

Tom Ogilvy

macro for clearing autofilter
 
if Activesheet.AutoFilterMode then
if Activesheet.FilterMode then
Activesheet.ShowAllData
End if
End if

--
Regards,
Tom Ogilvy


"BorisS" wrote in message
...
I'm having a little trouble with part of a macro. Before running what I

need
to run, I need to make sure the autofiler is clear (not turned off, just
clear of selections). I have the command
Selection.AutoFilter Field:="X"

in there 20 times for all the columns that are filtered right now. But I
noticed that if it gets to a column which is not part of the filter set

and
tries to run this command on that column, it gives an error. Problem is

that
I want to ensure that if another column is added to the filter set, that
column, too, is included in the macro set. Is there any way to basically

say
"for all filtered columns on this sheet, clear out the filters" (again,
maintaining the filtering capability on all columns that have it, but just
setting the selections to "all" for each).

Thx.
--
Boris





All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com