Pausing Worksheet_Change with checkbox

zankzank

New Member
Joined
Mar 21, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Dear all,
I would like to bypass Worksheet_Change when a checkbox is unticked.
I wrote the following code but the Worksheet_Change keeps firing no matter what

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo enableEventsOn:
Application.EnableEvents = False
If Not Intersect(Target, Range("R4:S40")) Is Nothing Then
Call macro_X
Active.Sheet.Range("S3").Value = "TRUE"
Application.EnableEvents = True
On Error GoTo 0
End If
End Sub

The checkbox is linked to cell S3 and when it is ticked S3 = TRUE
I would like the Worksheet_Change to stop firing when the checkbox is unticked (S3 = FALSE)

Any help is greatly appreciated.
Best,
Silvano
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You wont stop it firing but you can stop other lines running by adding a line at the top such as

If Range("S3").Value = "False" then Exit Sub
 
Upvote 0
Hi! First of all,
thank you for finding the time to answer my question: that was very kind of you!
I just wanted to say that , unfortunately, that does not seem to fix my problem: macro_X is still called even is the statement

If Range("S3").Value = "False" then Exit Sub

is added immediately after Private Sub Worksheet_Change(ByVal Target As Range)
 
Upvote 0
You wont stop it firing but you can stop other lines running by adding a line at the top such as

If Range("S3").Value = "False" then Exit Sub
Hi! First of all,
thank you for finding the time to answer my question: that was very kind of you!
I just wanted to say that , unfortunately, that does not seem to fix my problem: macro_X is still called even is the statement

If Range("S3").Value = "False" then Exit Sub

is added immediately after Private Sub Worksheet_Change(ByVal Target As Range)
 
Upvote 0

Forum statistics

Threads
1,216,031
Messages
6,128,420
Members
449,449
Latest member
Quiet_Nectarine_

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