Triggering a Macro for Drop-Down List Changes

by Allen Wyatt
(last updated January 16, 2014)

If you have Excel 97 and you create a macro that runs whenever a change occurs in your worksheet, you may have noticed an interesting phenomenon--the macro doesn't always run when you think it should. It runs just fine if you enter a new formula in a cell or enter a new value, but it doesn't run if you use data validation and someone picks something from the validation drop-down list.

Microsoft knows about this problem. In fact, you can find more information about it in the Knowledge Base, here:

http://support.microsoft.com/kb/172832

There are essentially several ways you can work around the problem. First, you could upgrade to a newer version of Excel. I'm not exactly sure which version it was corrected in, but I do know that in Excel 2003 selecting something from a data validation drop-down does trigger the Worksheet_Change event.

The second option is to use some other method of changing the worksheet data than with data validation. For instance, you could use a combo box from the Controls toolbox. Setting one up is a bit more difficult than using data validation, but much more versatile.

Finally, you could create a formula reference to the validated cell, and then trigger your macro from the Worksheet_Calculate event. For instance, if your validated cell is A7, then you could use the formula =A7 in a different cell. When the value in A7 changes (the user selects from the drop-down list), then a recalculation is begun because the results of the formula change. This, of course, triggers the Worksheet_Calculate event, where you could implement your macro. (Since the Worksheet_Calculate event can be triggered by lots of changes, you would need to add some checking code to your handler to make sure that the validation change is what ultimately triggered the event.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2398) applies to Microsoft Excel 97.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using Check Boxes

Check boxes, just like those used in Windows dialog boxes, can be a great addition to a worksheet. Here's how to add them and ...

Discover More

Table Borders Won't Print

Print a table and you may be surprised if it has no borders. That could be because you actually have the borders turned off. ...

Discover More

Identifying Merged Cells

Merging cells is a common task when creating worksheets. Merged cells can play havoc with the normal functioning of some of ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

MORE EXCELTIPS (MENU)

Assigning a Macro to a Keyboard Combination

Macros are a great way to expand what you can do with the data you place in Excel. You can make those macros even handier by ...

Discover More

Automatically Changing References to VBA Libraries

VBA libraries are used to provide some functions to your macros. These libraries are often tied to the version of Excel you ...

Discover More

Retrieving Drive Statistics

Need to gather some information about the drives on a system? It can be pretty easy to do using a macro, as shown in this ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share