Run Macro after Data Validation

pagrender

Well-known Member
Joined
Sep 3, 2008
Messages
652
Hello all,

I don't know if this is possible, but I thought I'd ask anyway.

I have data validation in cell B9 of the "Chart" tab. When the user makes a selection from the drop-down menu, is it possible to have Excel automatically run the "CreateChart" macro?

Thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The theoretical answer is Yes, this is possible, using the info you posted, for the "Chart" worksheet where the data validation in cell B9 is, right click on that sheet tab, left click on View Code, and paste this into the large white pane that is the worksheet module. Press Alt+Q to return to the worksheet.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$9" Then Exit Sub
If IsEmpty(Target) Then Exit Sub
Run "CreateChart"
End Sub

The success of the result will depend on the CreateChart macro, but the above steps would be the general approach.
 
Upvote 0
You can use a change event:

<font face=Calibri><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br>    <SPAN style="color:#00007F">If</SPAN> Target.Address = "$B$9" <SPAN style="color:#00007F">Then</SPAN> Applcation.Run "CreateChart"<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0

Forum statistics

Threads
1,203,242
Messages
6,054,350
Members
444,718
Latest member
r0nster

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top