Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Running a macro when selecting an item in a drop-down list
Could someone provide me with the code to run macro "MyMacro" when an item is
selected from a drop-down list located in cell H4? Chris |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Running a macro when selecting an item in a drop-down list
Right click the workhseet tab with the drop down in it and select view code.
Paste the following... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$H$4" Then Call MyMacro End Sub -- HTH... Jim Thomlinson "Christine" wrote: Could someone provide me with the code to run macro "MyMacro" when an item is selected from a drop-down list located in cell H4? Chris |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Running a macro when selecting an item in a drop-down list
Beautiful! Thank you very much, Jim.
"Jim Thomlinson" wrote: Right click the workhseet tab with the drop down in it and select view code. Paste the following... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$H$4" Then Call MyMacro End Sub -- HTH... Jim Thomlinson "Christine" wrote: Could someone provide me with the code to run macro "MyMacro" when an item is selected from a drop-down list located in cell H4? Chris |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Running a macro when selecting an item in a drop-down list
Any item will run the macro or certain items will run certain macros?
This worksheet change event will run MyMacro whenever any item is picked from the DV dropdown. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("H4")) Is Nothing Then Exit Sub On Error GoTo CleanUp Application.EnableEvents = False With Target If .Value < "" Then MyMacro End If End With CleanUp: Application.EnableEvents = True End Sub Gord Dibben MS Excel MVP On Fri, 1 Aug 2008 11:10:00 -0700, Christine wrote: Could someone provide me with the code to run macro "MyMacro" when an item is selected from a drop-down list located in cell H4? Chris |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Running a macro when selecting an item in a drop-down list
Thank you, Gord. I'll try your code as well.
"Gord Dibben" wrote: Any item will run the macro or certain items will run certain macros? This worksheet change event will run MyMacro whenever any item is picked from the DV dropdown. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("H4")) Is Nothing Then Exit Sub On Error GoTo CleanUp Application.EnableEvents = False With Target If .Value < "" Then MyMacro End If End With CleanUp: Application.EnableEvents = True End Sub Gord Dibben MS Excel MVP On Fri, 1 Aug 2008 11:10:00 -0700, Christine wrote: Could someone provide me with the code to run macro "MyMacro" when an item is selected from a drop-down list located in cell H4? Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to link macro to change an item in drop-down list | Excel Discussion (Misc queries) | |||
Selecting an item from a list | New Users to Excel | |||
Running a macro for each item in an Autofilter list | Excel Discussion (Misc queries) | |||
changing value of a cell by selecting an item from a drop down list | Excel Worksheet Functions | |||
Selecting an Item from a List and getting a different item to pop. | Excel Worksheet Functions |