ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to run on change (https://www.excelbanter.com/excel-discussion-misc-queries/103436-macro-run-change.html)

mr_teacher

Macro to run on change
 

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


--
mr_teacher
------------------------------------------------------------------------
mr_teacher's Profile: http://www.excelforum.com/member.php...o&userid=34352
View this thread: http://www.excelforum.com/showthread...hreadid=568797


Franz Verga

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




All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com