Run macros from multiple drop down lists in same sheet

MAJ0RMAJ0R75

New Member
Joined
Aug 10, 2011
Messages
2
Hi there,

I've been searching the net for a solution to my problem, however given my lack of understanding of VBA, have not been able to decipher solutions to similar problems previously posted.

I have created a form in Excel, which contains a number of drop down lists. I have also saved a number of macros which I would like to activate upon specific drop down selections being made. I have been able to get a set of macros to work on one drop down by using the following code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$17" Then
If Target = "Ex Factory" Then
Exf
ElseIf Target = "" Then
noexf
ElseIf Target = "Delivered" Then
noexf
ElseIf Target = "Delivered & Installed" Then
noexf
End If
End If
End Sub

I have read however that you can only use one instance of Private Sub Worksheet_Change(ByVal Target As Range) per worksheet.

I'd like to combine multiple instances of this code to different drop downs, for example adding the code below to the one above:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$3" Then
If Target = "Contract Review" Then
CR
ElseIf Target = "" Then
BR
ElseIf Target = "Bid Review" Then
BR
End If
End If
End Sub

I have read that the CASE statement can do this, but cannot work out how to translate what I want to achieve into the code.

Hopefully someone out there can offer a solution.

Many thanks in anticipation.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi MAJORMAJOR75,

Welcome to the forum!!

Yes, you're right as it wouldn't make sense to have more than one WorkSheet_Change event on a single sheet.

That said you can capture any cell change you wish and execute some code on it, i.e.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Select Case Target.Address
        Case Is = "$C$3"
            Select Case Target.Value
                Case "", "Bid Review"
                    Call BR
                Case "Contract Review"
                    Call CR
            End Select
        Case Is = "$C$17"
            Select Case Target.Value
                Case "", "Delivered", "Delivered & Installed"
                    Call noexf
                Case "Ex Factory"
                    Call Exf
            End Select
    End Select
    
End Sub

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,875
Members
452,949
Latest member
Dupuhini

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