Macro activated by list selection

Tim156

New Member
Joined
Nov 26, 2011
Messages
5
Hi I am new to the message board. I am able to record my macro but I am wondering how to activate the macro when I choose an item from a name list that I have created.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
A macro per item in the list. My list has three citys. Gargen City, Victoria and Wichita.

If I choose Wichita from the Drop list I want the macro to run and unhide the sheet called Wichita. Thanks.
 
Upvote 0
Are you referring to the Name Box up on the top left hand corner of the screen (to the left of the formula bar) or are you talking about a list using Data Validation?

If it is the former, you could run the event off the sheets SelectionChange event, insuring that Target is the same as your named range.

If the later, you could use the Change event and validate by both Target and Target's value.
 
Upvote 0
The code could look something like this:
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$C$4" Then ' Address C4 as given
    If Target.Value = "Run Macro1" Then Macro1 ' List Option and Macro name made up.
  End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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