Data Validation Drop Down List To Trigger Macro

pure vito

Board Regular
Joined
Oct 7, 2021
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Hopefully just a quick one 😬

My aim here is to use "C3" dropdown selection to trigger a macro based on the value, I have used Data Validation to populate the dropdown,

I have a working VBA that when text is entered manually into "C3" it runs the macro and it works fine but I can't seem to get the same result with the dropdown list,

I have been looking online for a solution but have just been coming across the same VBA,

Thanks in advance,

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("C3")) Is Nothing Then
        Select Case Range("C3")
            Case "Base Set Series": Baseset
           
        End Select
    End If
End Sub


1675752794741.png
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Code works for me.
Make sure that you have that worksheet change code in the sheet module of the sheet with the drop-down, not in a standard module & not in the ThisWorkbook module.
 
Upvote 0
Hey Peter,

Thank you, I do have this code in the sheet module,

But I'm making the selection using the dropdown and it's just not triggering I'm stumped 🤔

The Dropdown is populated from a list in another sheet

1675754680164.png


1675754463858.png
 
Upvote 0
Firstly, close right out of Excel and open up again in case your 'events' have become disabled.
Try the drop-down again.

If still no luck then add these two lines of code and choose the "Base Set Series" drop-down value again. If the first message box returns False, then perhaps the second one will shed some light on the issue.

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("C3")) Is Nothing Then
        MsgBox Range("C3").Value = "Base Set Series"
        MsgBox "|" & Range("C3").Value & "|"
        Select Case Range("C3")
            Case "Base Set Series": Baseset
           
        End Select
    End If
End Sub
 
Upvote 0
Hi,

Just make sure ...
Application.EnableEvents = True
 
Upvote 0
Thank you guy's for your assistance,

@Peter_SSs I closed the workbook and tried again with no luck, I then tried the code you have provided here, unfortunately this was the result 😔 so does this setup work for you Peter are you able to trigger a macro using a dropdown selection?

Hey @James006 thanks for dropping in, I also tried to include the line you have provided and still the same result I did try this previously also 🤔


1675755632538.png
 
Upvote 0
That message box result means that the value in C3 (the drop-down cell) is not identical to the typed value "Base Set Series"
Can you show what the second message box showed?

Check for leading/trailing/multiple internal spaces in both
Check that all "space" characters are normal space characters: CHAR(32)

For example, here I am checking the two space characters in C3

pure vito.xlsm
CDE
3Base Set Series3232
Sheet1
Cell Formulas
RangeFormula
D3D3=CODE(MID(C3,5,1))
E3E3=CODE(MID(C3,9,1))
 
Upvote 0
Solution
Apologies Guy's I have resolved the issue a space at the end of the text form the dropdown list was the issue 🤦‍♂️ had I tried another macro I might have resolved this issue sooner but I really appreciate you coming forward to help it's always appreciated, I thought I had exhausted all potential errors I just didn't see that space in the text I pasted the text from the code into the cell and seen the difference that way, Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,012
Members
449,060
Latest member
LinusJE

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