
Tips.Net > ExcelTips Home > Macros > Running a Macro When a Worksheet is Deactivated
Summary: You can easily configure Excel so that it runs a specific macro whenever a worksheet is deactivated. Just follow the easy steps in this tip. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
It is possible to configure Excel so that a macro of your choosing is executed every time a particular worksheet is deactivated. What does that mean? Simply that a macro can be run every time you click on a worksheet tab to leave the current sheet. All you need to do is follow these steps:
If you are using Excel 2007, then you define the requisite macro names in this manner:
Remember that a macro defined in this way is run every time the worksheet is deactivated, not just the first time. Think about how you use Excel; if you spend a fair amount of time hopping between worksheets in a workbook or between workbooks, it is possible to deactivate a worksheet several dozen times during the course of a session.
Tip #2955 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Got the Time? Understanding the ins and outs of working with times and dates can be confusing. Remove the confusion--ExcelTips: Times and Dates is an invaluable resource for learning how best to work with times and dates.
Check out ExcelTips: Times and Dates 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
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site