Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run Macro from a list

I have a data validation list in cell B2. The list consists of two choices
(Year, Month). Based on the users selection I would like to run a macro.
The maros are named Year and Month.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Run Macro from a list

I would try using the Change Event. Maybe something like this is what you
are asking for:

Sub Combox1_Change()

Select Case Combox1.Value

Case Is = "2008, Mar"
Call Macro1
Case Is = "2008, Jan"
Call Macro2
Case Is = "2007, Dec"
Call Macro3

End Select

End Sub
--
Cheers,
Ryan


"OsmoseTom" wrote:

I have a data validation list in cell B2. The list consists of two choices
(Year, Month). Based on the users selection I would like to run a macro.
The maros are named Year and Month.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Run Macro from a list

Try the following event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set b2 = Range("B2")
Set t = Target
If Intersect(t, b2) Is Nothing Then Exit Sub
v = b2.Value
If v = "Year" Then
Call yearr
Else
Call monthh
End If
End Sub

Note: I changed the spelling of the called routines to avoid ambiguities.
--
Gary''s Student - gsnu200798


"OsmoseTom" wrote:

I have a data validation list in cell B2. The list consists of two choices
(Year, Month). Based on the users selection I would like to run a macro.
The maros are named Year and Month.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Run Macro from a list

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

Application.Run .Value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"OsmoseTom" wrote in message
...
I have a data validation list in cell B2. The list consists of two choices
(Year, Month). Based on the users selection I would like to run a macro.
The maros are named Year and Month.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run Macro from a list

Gary,

You are a genius, I have been struggling with this for hours. Your code
worked great.

"Gary''s Student" wrote:

Try the following event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set b2 = Range("B2")
Set t = Target
If Intersect(t, b2) Is Nothing Then Exit Sub
v = b2.Value
If v = "Year" Then
Call yearr
Else
Call monthh
End If
End Sub

Note: I changed the spelling of the called routines to avoid ambiguities.
--
Gary''s Student - gsnu200798


"OsmoseTom" wrote:

I have a data validation list in cell B2. The list consists of two choices
(Year, Month). Based on the users selection I would like to run a macro.
The maros are named Year and Month.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Create a macro from drop down list (Validation List) in excel [email protected] Excel Programming 0 October 31st 06 12:42 PM
Macro list in Tools - Macro Ben Excel Programming 2 October 29th 06 08:20 PM
Display a macro at top of macro list? StargateFanFromWork[_3_] Excel Programming 1 January 4th 06 12:37 PM
How to create a macro that compares a list to another list Rampa New Users to Excel 1 January 13th 05 01:15 PM
Show Macro list (tools-macro-macros) Hafeez Esmail Excel Programming 5 December 31st 03 09:54 PM


All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"