Run a macro when an item is selected from a drop down list?

FatalLordes

Board Regular
Joined
Dec 22, 2017
Messages
76
Office Version
  1. 365
Platform
  1. Windows
Hi all.... so I have a macro that is presently running perfectly when the user hits the button on the spread sheet to run the macro. What I would love to be able to do is have that macro run automatically every time the user selects an item from a drop down list on the sheet. It is the same macro regardless of the item selected on the drop down list but it needs to run each time a new selection is made on the drop down list. So user expands the list, selects an item and BANG, macro runs. How would I go about doing this in Excel 365? Thanks in advance
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Put the following code in a sheet events.
Change C3 for the cell where you have your dropdown
Change MyMacro for your macro

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Target.Address(0, 0) = "C3" Then
    Call MyMacro
  End If
End Sub

Note Sheet Event:
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Put the following code in a sheet events.
Change C3 for the cell where you have your dropdown
Change MyMacro for your macro

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Count > 1 Then Exit Sub
  If Target.Address(0, 0) = "C3" Then
    Call MyMacro
  End If
End Sub

Note Sheet Event:
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
OMG! You are fabulous! That worked (after I googled how to find sheet event). Thank you! Thank you! Thank you! :)
 
Upvote 1

Forum statistics

Threads
1,223,836
Messages
6,174,923
Members
452,592
Latest member
Welshy1491

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