in VBA - Remove Custom Settings from Filter(s)

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Using Office 2003

I would like to reset any custom filter settings from all columns.

The following resets Column 1 only:

Selection.AutoFilter Field:=1

What is the VBA code to reset Columns 1-17?

TIA Dennis
 
Dennis,

Selection.AutoFilter

You could have found that out by yourself if you had just used Macro Record
(as I did).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Bob,

I am using Walkenbach's 2003 Book with CD and Google Search.

I first query the CD using various "finds." In over 1000 pages there was no
reference to my specific question. Then I went to Google also with no answer.

To be sure, knowing how to ask questions needs to also be learned.

In your vast VBA experience you could assume that Selection.Autofilter would clear
the filters.

To someone learning, I would assume that "Selection.Autofilter" just selected the
operation Autofilter.

With all due respect, cut some slack for we beginners.

This kind of reminds me of being told to look up a word in the dictionary to check
it's spelling. You know where I am going.

Thanks Dennis

P.s Single questions with non-complex answers and keeps the MVP stats up No?
 
Dennis said:
Bob,

I am using Walkenbach's 2003 Book with CD and Google Search.

I first query the CD using various "finds." In over 1000 pages there was no
reference to my specific question. Then I went to Google also with no answer.

Well
To be sure, knowing how to ask questions needs to also be learned.

In your vast VBA experience you could assume that Selection.Autofilter would clear
the filters.

To someone learning, I would assume that "Selection.Autofilter" just selected the
operation Autofilter.

With all due respect, cut some slack for we beginners.>
This kind of reminds me of being told to look up a word in the dictionary to check
it's spelling. You know where I am going.

Thanks Dennis

P.s Single questions with non-complex answers and keeps the MVP stats up
No?
 
Interesting.

I would like to re-aply the autofilter in VBA.

Using the Run Macro technique I determined that the Macro entry to turn ON Autofilter
is: Selection.Autofilter

The Macro entry to turn ON the autofilter is also

Selection.Autofilter

What is the VBA code to specifically turn OFF the ON the filter?

Toggling Selection.Autofilter does not do it.

Running "Selection.Autofilter = False" bombs

and

Running "Selection.Autofilter = True" errors

I looked in Walkenbach's book and am currently looking at Google with a search for
Autofilter & Select

TIA Dennis
 
The .autofilter works like a toggle.

When I'm not sure if the autofilter is on (or I want to apply it to a different
range), I can explicitly turn it off with something like:

activesheet.autofiltermode = false

xl/VBA won't yell if there's not a filter applied.

And you could check various stages of autofilter:


With ActiveSheet
If .AutoFilterMode Then
MsgBox "Has dropdown Arrows!"
If .FilterMode Then
MsgBox "Some filter is active!"
End If
End If
End With

(woohoo. Another post! <vbg>)
 
Back
Top