bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Tools > Toggling AutoFilter

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:

  1. Choose Customize from the Tools menu. Word displays the Customize dialog box.
  2. In the actual Excel menus (not the Customize dialog box), select the Filter option from the Data menu.
  3. As you hold down the Ctrl key, drag the AutoFilter option from the menus and drop it someplace in a toolbar. (If you don't hold down the Ctrl key, the menu option is moved. You don't want to do this, so hold down the Ctrl key.)
  4. Click on the Close button on the Customize dialog box.

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


More Power! Expand your skills and make Excel really sing! It's all possible with macros. The best resource anywhere for macros is ExcelTips: The Macros. Check it out today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home
Vital News Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)