Forum Discussion
DrJ_Thesising_101
Aug 09, 2023Copper Contributor
How to clear a cell based on a change in a different cell
Hi All I have created a dependent drop down list where e.g. A3 is Fruit, B3's drop down list = apple, banana, kiwi etc. And if the user changes A3 to Veggies, B3's drop down list = carrot, peas, e...
NikolinoDE
Aug 09, 2023Gold Contributor
Untested
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Intersect(Target, Me.Range("A:A"))
If Not rng Is Nothing Then
Application.EnableEvents = False ' Disable events to prevent recursive calls
For Each cell In rng
If Not IsEmpty(cell.Offset(0, 1)) Then
cell.Offset(0, 1).ClearContents
End If
Next cell
Application.EnableEvents = True ' Enable events again
End If
End Sub
This code will clear the cell in column B (offset by one column to the right) that is in the same row as the changed cell in column A. Make sure you place this code in the worksheet module of the specific sheet where you want this behavior to happen.
- DrJ_Thesising_101Aug 09, 2023Copper ContributorThank you so much!!!!