Worksheet_Change / Worksheet_SelectionChange with Data Validation

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,924
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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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