Worksheet_Change / Worksheet_SelectionChange with Data Validation

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,926
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Further to my thread here:


Here is the code:

Rich (BB code):
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

    With Application
    
        .EnableEvents = False
        
        Select Case Target.Column
        
            Case 1
            
                Me.Cells(Target.Row, 2).Select
        
            Case 2
            
                Me.Cells(Target.Row, 3).Select
        
            Case 3
            
                Me.Cells(Target.Row, 4).Select
        
            Case 4
            
                Me.Cells(Target.Row, 1).Select
        
        End Select
        
        .EnableEvents = True
        
    End With
    
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    MsgBox "Bug!"
    
End Sub


I have finally found what the problem is.

In Sheet1, if you changed the cells A1, B1, C1 or D1, the Worksheet_Change event kicks in as expected.


When it runs to the End Sub, The Worksheet_SelectionChange event gets triggered (which I don't understand but that's beside the point).


However, if some of the cells, say A1 and B1 contains data validation, then changing their values will again kick off the Worksheet_Change event but this time, when it runs to the End Sub, the Worksheet_SelectionChange event will NOT kick in.
 

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
How are you changing the values in the cells with DV?
 
Upvote 0
Then changing the cell doesn't then automatically select another cell, so there is no reason for the SelectionChange event to fire.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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