
Tips.Net > ExcelTips Home > Macros > Creating Macros > Macro Fails after AutoFilter
Summary: When developing a macro that others may use, you might want to test it out to make sure it works properly if an AutoFilter is in effect. If it doesn’t, you can turn off the AutoFilter with a simple single-line command. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
In testing new macros that you develop, you may find that the macro fails when it is run and the information in a worksheet is filtered using the AutoFilter. This can happen because the macro may expect that all the information in the worksheet is available, or it may try to update information that is not visible on the screen.
The best solution to this problem is to make sure that the macro turns off the AutoFilter feature. This can be easily done by adding the following line of code near the beginning of the macro:
ActiveSheet.AutoFilterMode = False
This ensures that AutoFilter is off, and removes the problems that AutoFiltered data may present for your macro.
Tip #3314 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Save Time and Money! Many people need to keep track of employee time, but don't know where to start when it comes to creating a spreadsheet. Here's a way to save time, effort, and money with ready-to-use timesheet templates.
Check out Timesheet Templates today!
If you have tons of data to analyze, one of the best tools in Excel's arsenal is the PivotTable. Learn how to use this tool to analyze your data. (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