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.
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
is it one name from a list that starts the macro or a macro per item in the list?
 

Tim156

New Member
Joined
Nov 26, 2011
Messages
5
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.
 

Tim156

New Member
Joined
Nov 26, 2011
Messages
5

ADVERTISEMENT

The sheet name is Weely Volume and the cell is in c4.
 

rosenbe

Board Regular
Joined
Nov 24, 2011
Messages
67
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.
 

Tim156

New Member
Joined
Nov 26, 2011
Messages
5

ADVERTISEMENT

A list using data validation.
 

rosenbe

Board Regular
Joined
Nov 24, 2011
Messages
67
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,093
Members
414,501
Latest member
mdhaumyu

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
Top