call macro with validated dropdown menu

needhelp2

Active Member
Joined
Apr 19, 2011
Messages
250
Hello everybody,

I am using excel 2007.I have create some macro that if some value select from validated drop down then it calls for my saved macro to run

Is there any easy way to run it?
my macro is saved with name of macro2.

Best Regards,
Rob.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
try something like this in worksheet module:

Code:
[/FONT]
[FONT=Courier New]Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
    msgbox "run macro2??"[/FONT]
[FONT=Courier New]    call macro2[/FONT]
[FONT=Courier New]End if[/FONT]
[FONT=Courier New]
 
Upvote 0
wao thats great Pedie i want to knwo that if i have some other macros e.g macro3,macro47 so i can use the same script?
 
Upvote 0
That was just an example...you can it the way you want to...
Let us say you have 3 macros...and 3 validation list...[apple, mango and banana...]

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
'sometime you may want to turn off events and then
'run..and turn it back on again
if target.value = "Apple" then call macro1
if target.value = "Mango" then call macro2
if target.value = "Banana" then call macro3
'etc....
End if
end sub
 
Upvote 0
Its really helpfull for me.But now my macros are not being working when ever i select like mango from drop down.....it attached with Macro2.
 
Upvote 0
Try this way..i have not tested this code as my office is not installed in my notebook:)

Code:
[/FONT]
[FONT=Courier New]If Not Intersect(Target, Range("A1")) Is Nothing Then
'sometime you may want to turn off events and then 
'run..and turn it back on again[/FONT]
[FONT=Courier New][/FONT] 
[FONT=Courier New]Application.EnableEvents = False[/FONT]
[FONT=Courier New]
if target.value = "Apple" then 
call macro1
end if
if target.value = "Mango" then 
call macro2
end if
if target.value = "Banana" then
 call macro3
end if
'etc....
Application.EnableEvents = True

End if
end sub
 
Upvote 0
Thanks i modify a bit in script provided by your its perfect now......... Thanks you very very very much.I haven't any more words to say thanks but you can give me a chance to say any more :-(
 
Last edited:
Upvote 0
Hi Needhelp2,

I have the same probelm and need hemp solution as you, but I am not VBA expert like u guys. I wonder if u could kindly share with me your solution ? I have dropdown list of 11 entries, and 11 macros that i hope to run with each selected entry from the dropdown ..

Many tkx,
Jason
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,822
Members
452,946
Latest member
JoseDavid

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