Disabling events

confusion123

Active Member
Joined
Jul 27, 2014
Messages
400
This event starts when a cell is changed:

Code:
Private Sub Worksheet_Change(ByVal Target As range)

This event starts when a cell is selected:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As range)

Is there any way I can have the first to run but not the second?

Adding

Code:
Application.EnableEvents = False

to the end of the first sub routine didn't help.

Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
What are you actually doing to trigger the events?

Setting EnableEvents to False should typically not be done at the end of a routine since no further events will be fired unless you manually run code to reset events, or restart Excel.
 
Upvote 0
I am trying to work out if cells on a particular row has changed value.

So if any of cells A1 to E1 has changed value, then clicking on cell F1 triggers an event, otherwise don't trigger the event.
 
Upvote 0
Do you only need to monitor 1 row or multiple? If it's multiple, do you need to run the selection change code in succession for each row you select that has had a cell changed?

I think a bit more detail would help us to provide a better solution.
 
Upvote 0
The way the spreadsheet works is as follows:

The user makes some changes to row 1, cells A1 to E1. If a change has been made, clicking on G1 will trigger an event.

The next time the user clicks on G1, nothing should happen unless some cell A1 to E1 changes.
 
Upvote 0
If I may jump in on this, you could easily achieve this by setting a flag each time a cell is changed in the A1:E1 Range

Something like this :
Code:
Private bFlag As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("a1:e1")) Is Nothing Then
        bFlag = True
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = Range("g1").Address And bFlag Then
        'run your event code here ..
        bFlag = False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,401
Messages
6,055,182
Members
444,768
Latest member
EMGVT

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