
Tips.Net > ExcelTips Home > Tools > Toggling AutoFilter
Summary: Using the menu sequence Data | Filter | AutoFilter, you can toggle AutoFilter on and off for a data table. This tip explains how to create your own toolbar button that does the same thing (toggling) as the AutoFilter menu option. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
One of the handy features of Excel is AutoFilter. It allows you to quickly filter any list by the contents of a particular column. If you use the Customize option from the Tools menu, you can create an AutoFilter tool to your toolbars. This tool uses an image of a funnel and an equal sign.
The tool is a bit deceptive, however; it is not the same as the Data | Filter | AutoFilter option. The menu option is a toggle condition. If you have a cell selected in a list, and you choose the menu option, then the AutoFilter controls appear at the top of each column in the list--there are no other changes to the list. If you use the AutoFilter tool, not only do the controls appear, but Excel filters the list based on the cell you had selected when you used the tool.
Another difference between the two is that the AutoFilter menu option functions like a toggle--choose it once, and the AutoFilter is applied; choose it again and it is removed. The AutoFilter tool doesn't do that; it only applies the AutoFilter.
What if you want a toolbar option that is a real toggle, just like the menu option. There are two approaches you can use to solve this problem. The first involves the use of a simple macro:
Sub ToggleAutoFilter()
On Error GoTo errMessage
Selection.AutoFilter
Exit Sub
errMessage:
MsgBox "Select a cell in the range to be filtered.", vbOKOnly
End Sub
All you need to do is assign the macro to a toolbar button or to a shortcut key, and you can turn AutoFilter on and off, just as if you selected the option from the menus.
The second option may be even simpler. Just follow these steps:
The result is that the menu option is not accessible from the toolbar. You can click on it to turn AutoFilter on and off, at will.
Tip #2710 applies to Microsoft Excel versions: 97 2000 2002 2003
Don't Go in Debt for Christmas! Tired of trying to keep up with the Joneses for Christmas? Want to enjoy the season rather than dread the aftermath? Learn how you can avoid the financial traps that spring up every Christmas.
Check out Top Fifteen Tips for Financing Christmas today!
It doesn't matter if you are a beginner or expert, the ExcelTips archives are the fastest way to improve your productivity. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site