VBA to check for data validation selection

bdepolo

New Member
Joined
Apr 20, 2010
Messages
19
Hi Everyone,

I have 3 data validation boxes that each draw their choices from each other. So the user will select a category in H2 which will decide the available choices in I2 which will then allow certain choices only for J2. I wanted to make it so that when H2 is changed I2 and J2 are cleared out. I've tried doing it through the SelectionChange Event, but with data validation it seems like just clicking in the cell runs the SelectionChange event. Is there another way this could be done? If I can provide any further details that would help let me know.

Below is my SelectionChange code

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Not Intersect(Target, Range("H2:H75")) Is Nothing Then
    
        If ActiveCell.Validation.Type = xlValidateList Then
             ActiveCell.Offset(0, 1).Value = ""
             ActiveCell.Offset(0, 2).Value = ""
        End If
        
    ElseIf Not Intersect(Target, Range("I2:I75")) Is Nothing Then
    
        If ActiveCell.Validation.Type = xlValidateList Then
             ActiveCell.Offset(0, 1).Value = ""
        End If
        
    End If

End Sub
Thanks in advance
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
That seems to lead to the same result. Just clicking into the cell with the validation triggers the macro to run and clear out the other 2 cells. I'm not sure there's a way around it since I don't want anything to run unless a change is made to in the cell value.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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