Fix Excel VBA Errors When Clearing Dependent Drop-Down Cells
Question details
The user needs a Worksheet_Change macro to handle changes to multiple rows without a run-time error.

- Product
- Microsoft Excel VBA
- Device & OS
- not provided
- Scenario
- A worksheet macro clears a dependent drop-down cell in column J when the corresponding cell in column I changes.
- Observed behavior
- The macro works for a single row but produces a run-time error when multiple rows are cleared at once.
Confirm that column I contains the controlling cells and column J contains the dependent drop-down cells. Open the worksheet's code module in the Visual Basic Editor and locate its existing Worksheet_Change procedure.
Loop Through Changed Cells to Support Multiple Rows
Use this approach when clearing or pasting multiple cells in column I should also clear the corresponding cells in column J.
Worksheet_Change can receive a range containing multiple cells. Intersecting that range with column I and processing each cell individually avoids treating the entire range as a single cell.
The macro temporarily disables events so clearing column J does not trigger another Worksheet_Change event. Its error handler restores events if an error occurs.
In Excel, open the Visual Basic Editor, then find and double-click the affected worksheet in Project Explorer.
Replace the existing Worksheet_Change procedure with this code, or merge its logic into the existing procedure if it handles other changes: Private Sub Worksheet_Change(ByVal Target As Range) Dim changedCells As Range Dim cell As Range Dim errorMessage As String Set changedCells = Intersect(Target, Me.Columns(9)) If changedCells Is Nothing Then Exit Sub On Error GoTo ErrorHandler Application.EnableEvents = False For Each cell In changedCells.Cells Me.Cells(cell.Row, 10).ClearContents Next cell Application.EnableEvents = True Exit Sub ErrorHandler: errorMessage = Err.Description Application.EnableEvents = True MsgBox "Unable to clear dependent cells: " & errorMessage, vbExclamation End Sub
Return to the worksheet, change one cell in column I, and then clear several cells in column I at once. Check that the corresponding cells in column J are cleared.

Skip Changes Involving More Than One Cell
Use this minimal fix if the existing macro only needs to handle single-cell changes.
Manage Dependent Drop-Down Worksheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and editing Excel workbooks. It can ease migration, although it does not fix an Excel VBA error and macro support varies by WPS edition and platform.

Frequently Asked Questions
Why does the macro fail when I clear multiple cells?
Worksheet_Change receives all changed cells in Target. Code that assumes Target is a single cell can fail when several cells are cleared or pasted at once. Loop through the relevant cells or exit when Target.CountLarge is greater than one.
Where should I put the Worksheet_Change code?
Open the Visual Basic Editor and double-click the affected worksheet in Project Explorer. Place the event procedure in that worksheet's code module, not in a standard module.
Will ClearContents remove the drop-down list?
ClearContents removes the cell's value or formula but normally leaves its data validation rule intact, so the drop-down remains available.
What if Excel events remain disabled after a macro error?
In the Visual Basic Editor, open the Immediate window and run Application.EnableEvents = True. Add error handling to the macro so it restores events if a later error occurs.
Will this macro run when a formula result changes?
Worksheet_Change does not run solely because a formula recalculates. If column I changes through recalculation rather than a direct edit or paste, a different approach, such as Worksheet_Calculate, is needed.




