Worksheet_SelectionChange Not recogizing When A Cell Has Changed Value

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am having difficulty in getting my worksheet_selection change code to work.

In my example, cell W12 has a list validation. When I make a selection from the list, I need some code to run, so I expected that a worksheet_selection code procedure would work.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Stop
    If Not mbevents Then Exit Sub
    tmrow = Target.Row 'trow = Target.Row
    tmcol = Target.Column 'tcol = Target.Column
    If tmcol < 13 Or tmcol > 16 Then
        If Target.Value = "" Then Exit Sub
    End If
    mbevents = False
    . . . more code
end sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
When you make a selection from a validation list normally you don't change selection; you should rather use the Worksheet_Change event.
Anyway, do you mean that when you change the selection on the worksheet you macro do not reach that Stop?
If you right-click on the tab with the name of the worksheet that you use and select Display Code do you see the code of your Sub Worksheet_SelectionChange?

Additionally (for the next step) where the variable "mbevents" has been declared? Where is it set or reset?
 
Upvote 0
Solution
Thank you Anthony for the nudge. I used a worksheet change event instead, and I think now I have it working.
I've not quite grasped the difference between a worksheet change vs. a selection change event.
 
Upvote 0

Forum statistics

Threads
1,215,235
Messages
6,123,779
Members
449,123
Latest member
StorageQueen24

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