PDA

View Full Version : Testing whether filtering is active.



yoinkster
10-28-2008, 04:26 AM
Hey guys,

I have a macro that filters on different columns depending on what option is selected on a userform. This works fine when the filtering is already switched on on the worksheet but falls over when there is none.

Is there a way of saying like
If autofiltering is off then
switch it on

Bob Phillips
10-28-2008, 05:24 AM
Check out



ActiveSheet.AutoFilterMode

yoinkster
10-28-2008, 05:54 AM
So I want something like

If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = True
End If


But this doesn't work, the test on the if statement seems to work but I can't get it to turn on the filter. Have I been too hopeful on how easy that step is?

Bob Phillips
10-28-2008, 05:56 AM
No, you have to set the filter, which means identifying the range to be filtered, and the column within that range.

If you read the help, you will see that you can set it to false to remove the arrows, but you cannot set it to tru.