Macros via Dropdown list

Bxl

New Member
Joined
Feb 9, 2022
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hi all, I have a spreadsheet which has a number of Macro's 1-10 and I am trying to call these macro's using a dropdown list Temp1-10). This is looked up in cell F2 and this is where I try to call the Macro from. I have tried numerous solutions and I just don't seem to be able to get it to work. Any ideas?

Many thanks,
BXL


Img.jpg
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I suggest you add some code to trigger the correct macro when the selection changes

It seems that F2 changes when D2 changes. So a change in D2 will be the trigger.
The code below runs whenever a cell is changed on the worksheet. If the changed cell is D2, it runs the macro name in F2.

1. give D2 and F2 a range name. I named D2 as selector, and F2 as macro, but you can use different names (just change my code below)
2. Press Alt F11 to get to the VBA code window
3. At left, you will see a list of the sheets in your workbook. Doubleclick the sheet name with D2 and F2 in it
4. This will open an empty code page for that sheet. Paste this code into it
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = Range("selector").Address Then Application.Run Range("macro").Text
End Sub
(If you have used different range names, change the code to use them instead of my names)
5. Close the VBA code window and test it
 
Upvote 0

Forum statistics

Threads
1,215,513
Messages
6,125,262
Members
449,219
Latest member
daynle

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