IF AutoFilter is on, turn it off

G

Guest

Hi all....

I know I can toggle the Autofilter on and off with the line
"Selection.Autofilter", but when I send a user to a Sheet from my Main Menu,
I do not know if Autofilter is on there, or not.......I would like to turn it
off if it has been left on........help please.....

Vaya con Dios,
Chuck, CABGx3
 
H

Harald Staff

Hi Chuck

Sub test()
MsgBox ActiveSheet.AutoFilterMode
End Sub

HTH. Best wishes Harald
 
G

Guest

CLR, add the following line to your code:

If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False

HTH
 
G

Guest

Thank you very much.......of the ones suggested so far, I think this is the
method I prefer....

Thanks again,
Vaya con Dios,
Chuck, CABGx3
 
G

Guest

The only thing about Toppers version is, if auto filter is already off, it
generates an error. Unless of course you trap that error...?
 
D

Dave Peterson

You sure?

It didn't cause an error for me.

Any chance your workbook didn't have a sheet named "sheet1"? That would cause
an error.
 
G

Guest

WOW, thanks for the warning.....I was just about to test it when this post
came in......so, since I don't know how to "trap that error", I reckon I'll
fall back to using the method you suggested........I would have selected it
first except that I thought the other one would be easier for my little mind
to remember for next time.....

Thanks again,
Chuck, CABGx3
 
D

Dave Peterson

Try it anyway.
WOW, thanks for the warning.....I was just about to test it when this post
came in......so, since I don't know how to "trap that error", I reckon I'll
fall back to using the method you suggested........I would have selected it
first except that I thought the other one would be easier for my little mind
to remember for next time.....

Thanks again,
Chuck, CABGx3
 
G

Guest

Dave is right, my appologies to Toppers, CLR and the confusion my post
caused. Either code version will work.
 
G

Guest

Thanks Dave........I did, and (lol) I thought there was something wrong with
my machine, because it worked ok<g>.......I do appreciate you catching this
tho.....

Thanks again,
Vaya con Dios,
Chuck, CABGx3
 
G

Guest

No problem, quartz.......
Thanks for participating and doing what you thought was the right
thing.....You're obviously 'way ahead of me with VBA, so please feel free to
jump in and help me at any time<g>. I do appreciate you showing me a second
way to "skin the cat". You're right, both methods work fine.

Thanks again,
Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top