+ Reply to Thread
Results 1 to 4 of 4

Macro choice triggered by a drop-down list

Hybrid View

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Orlando, FL
    MS-Off Ver
    Office 365 for Business
    Posts
    89

    Macro choice triggered by a drop-down list

    I am trying to write a macro that will:
    Run the macro "Sub Emailstraightruckreq()" (or Module48) if the second value in my drop-down list in cell A28 of my current worksheet is selected.
    I also want this macro to run the macro "Sub Emailshowreq()" (or Module8) if the first value in my drop-down list in cell A28 of my current worksheet is selected.

    I don't know where to start, or even if you can run two macros within a macro.

    I hope this makes sense??

    Thank you.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro choice triggered by a drop-down list

    One option, put in the worksheet change event. You will have to modify to meet your specific information.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1") '<==your sheet name goes here
    
    If Not Intersect(Target, ws.Range("A28")) Is Nothing Then
        Select Case Target.Value
            Case "test1" '<== your first value goes here
                Call Emailshowreq
            Case "test2" '<== your second value goes here
                Call Emailstraightruckreq
            'you can contine on for multiple cases if needed
        End Select
    End If
    
    End Sub
    If you don't want this as a worksheet change and want it only done when you want to run it as a macro then


    Sub Macro1()
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1") '<==your sheet name goes here
    
        Select Case ws.Range("A28").Value
            Case "test1" '<== your first value goes here
                Call Emailshowreq
            Case "test2" '<== your second value goes here
                Call Emailstraightruckreq
            'you can contine on for multiple cases if needed
        End Select
    
    End Sub
    Last edited by stnkynts; 12-05-2012 at 04:44 PM.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro choice triggered by a drop-down list

    Something like this should work. Change "First value" to be the actual first value and change "Second value" to be the actual second value. This code goes in the worksheet module of the worksheet that contains the drop-down list in cell A28
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        If Target.Address = "$A$28" Then
            Select Case Target.Value
                Case "First Value":     Call Module48.Emailstraightruckreq
                Case "Second Value":    Call Module8.Emailshowreq
            End Select
        End If
        
    End Sub

    [EDIT]: Beat to it by stnkynts
    Last edited by tigeravatar; 12-05-2012 at 04:48 PM. Reason: Added edit
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    10-24-2011
    Location
    Orlando, FL
    MS-Off Ver
    Office 365 for Business
    Posts
    89

    Re: Macro choice triggered by a drop-down list

    I used the second option. It worked great! You are awesome!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1