View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Franz Verga Franz Verga is offline
external usenet poster
 
Posts: 459
Default Macro to run on change

mr_teacher wrote:
Hi all,

Sure there is a really simple answer to this one - but if I can crack
this it will really help.

I have two drop down lists where the user can select from three
different options.

What I would like to happen is that when anyone selects a different
option from the drop down list then the Macro Sort5ColumnGrid is
automtically run.

IS this possible?

Thanks for any help

Regards

Carl


Hi Carl,

you need to use the Worksheet_Change event.

Right click on the tab of the sheet with the drop down list and select Show
Code. Copy & past this code:

Private Sub Worksheet_Change(ByVal Target As Range)
Call Your_macro
End Sub


where you have to change Your_macro with the real name of your macro. In
this way every time that something change on your worksheet, the macro will
run.

If, instead, you want to run the macro only if a specific range change, use
this code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Call Your_macro
Else
Exit Sub
End If
End Sub

where you have to change A1 with your real range and Your_macro with the
real name of your macro.


--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy