Fix Excel VBA Errors When Resetting Dependent Drop-Down Lists
Question details
Prevent VBA errors when a changed cell has no data validation while resetting dependent drop-down selections.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A Worksheet_Change macro resets dependent drop-down cells after a user changes a parent selection.
- Observed behavior
- Reading Validation.Type raises an error when the changed cell does not contain data validation.
Identify the worksheet and columns used by the parent and dependent lists, and check whether the sheet already has a Worksheet_Change procedure. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros only if you trust the file.
Safely check validation before resetting dependent lists
Use this worksheet event to ignore multiple-cell changes and cells without list validation, then reset dependent cells without triggering the event again.
The example treats column M as the first parent and column N as the second parent. A change in M resets N and O; a change in N resets O.
A worksheet can have only one Worksheet_Change procedure. If one already exists, merge the relevant logic into it rather than adding a second procedure.
In Excel, right-click the relevant sheet tab, select View Code, and find its Worksheet_Change procedure if one already exists.
In the worksheet's code window, add the following procedure or merge its logic into the existing Worksheet_Change procedure: Private Sub Worksheet_Change(ByVal Target As Range) Dim isList As Boolean Dim previousEvents As Boolean Dim errorMessage As String If Target.CountLarge > 1 Then Exit Sub If Intersect(Target, Me.Range("M:N")) Is Nothing Then Exit Sub On Error Resume Next Err.Clear isList = (Target.Validation.Type = xlValidateList) If Err.Number <> 0 Then Err.Clear On Error GoTo 0 Exit Sub End If On Error GoTo 0 If Not isList Then Exit Sub previousEvents = Application.EnableEvents On Error GoTo CleanUp Application.EnableEvents = False If Target.Column = 13 Then Target.Offset(0, 1).Resize(1, 2).Value = "Please Select" ElseIf Target.Column = 14 Then Target.Offset(0, 1).Value = "Please Select" End If CleanUp: errorMessage = Err.Description Application.EnableEvents = previousEvents If Len(errorMessage) > 0 Then MsgBox errorMessage, vbExclamation End Sub
Change Me.Range("M:N"), the column numbers, offsets, and "Please Select" to match your worksheet. Return to the sheet and test a validated parent cell, a cell without validation, and a multiple-cell paste.

Manage spreadsheet drop-down lists with WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easier to move existing files. It does not repair Excel's VBA environment, and macro compatibility should be tested separately.

Frequently Asked Questions
Why does Validation.Type raise an error?
The property can raise an error when the changed cell has no data validation. Test it with narrowly scoped error handling before checking whether its type is xlValidateList.
Where should I put the Worksheet_Change code?
Right-click the relevant worksheet tab in Excel and select View Code. Put the event procedure in that worksheet's code module, not in a standard module.
Why does the macro ignore pasted ranges?
The Target.CountLarge check exits when more than one cell changes. Supporting multi-cell pastes requires additional logic to process each relevant cell.
How do I clear the dependent cells instead of showing a placeholder?
In the assignment statements, replace "Please Select" with an empty string (""). Check the dependent cells' validation rules and worksheet protection before testing.
What if Excel events remain disabled after a macro stops?
In the VBA editor, open the Immediate window with Ctrl+G, enter Application.EnableEvents = True, and press Enter. The cleanup handler in the example restores the previous event setting after a handled error.




