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

Tips.Net > ExcelTips Home > Macros > Creating Macros > Macro Fails after AutoFilter

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!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home
Vital News Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

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

 

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.)