macros

edward_laton

New Member
Joined
Sep 16, 2002
Messages
3
Hello everyone
Is there a way to use dropdown menus to run
a macro, or is there a way to use VB to do this.

Any help would be helpfull

Ed
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
1. On say Sheet1, select cell A1 (colour the cell say yellow and put a border around the cell to highlight it).
2. Go to Data/Validation.
3. In the "Allow" dropdown menu select "List".
4. In the "Source" box type "Print", "Copy", "Close" (without the apostrophes but include the commas between the expressions). For the sake of this demo, I am assuming that you have a print, copy and close macro (change to whatever).
5. OK.
6. Alt F11 and enter the following macro in the sheet1 module:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column <> 1 Then Exit Sub
If Target = "Print" Then Macro1 ' Change to name of your first macro
If Target = "Copy" Then Macro2 ' Change to name of your second macro
If Target = "Close" Then Macro3 ' Change to name of your third macro
End Sub

7. To test the above, put the following macros in a normal module (in the VBA Editor - Insert menu / Module):

Sub Macro1()
MsgBox "Hello - Print macro"
End Sub

Sub Macro2()
MsgBox "Hello - Copy macro"
End Sub

Sub Macro3()
MsgBox "Hello - Close macro"
End Sub

8. Save the file.
9. Return to sheet1, activate cell A1 and make your selection from the drop down menu.


Regards,

Mike
 
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,085
Members
449,064
Latest member
MattDRT

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