Worksheet_Change event

sanilmathews

Board Regular
Joined
Jun 28, 2011
Messages
102
Hello,

I am looking to modify the below code in a way that when the user selects "Yes" in the drop down in cell A1, macro should just Exit sub. And when user selects "No" in the drop down the code should trigger "MyMacro".

Code:
Private Sub Worksheet_Change (ByVal Target As Range) 
If Intersect (Target, Me.Range("A1")) Is Nothing Then Exit Sub
Application.EnableEvents = False
On Error GoTo ErrorHandler 
Call MyMacro
ErrorHandler:
Application.EnableEvents = True
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If UCase(Trim(Intersect(Target, Me.Range("A1")))) = "YES" Then Exit Sub
Application.EnableEvents = False
On Error GoTo ErrorHandler
Call MyMacro
ErrorHandler:
Application.EnableEvents = True
End Sub
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
Application.EnableEvents = False
On Error GoTo ErrorHandler
If Target = "No" Then Call MyMacro
ErrorHandler:
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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