VBA worksheet event to delete dependent validation list

cidfidou

Board Regular
Joined
Jan 19, 2009
Messages
163
Hi Excel jedis,

how can I change the below code to only clear a specific cell instead of column . (lets say cell B2 and C2 and clearing C2 when B2 i changed.. )

As usual, thanks inadvance



Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 2 Then
If Target.Validation.Type = 3 Then
Application.EnableEvents = False
Target.Offset(0, 1).ClearContents
End If
End If

exitHandler:
Application.EnableEvents = True
Exit Sub

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
how can I change the below code to only clear a specific cell instead of column . (lets say cell B2 and C2 and clearing C2 when B2 i changed.. )
Isn't that what it is already doing? If target column is B the corresponding cell from column C is cleared.
 
Upvote 0
Hi fishboy,

this is correct but I am trying in vain to define a specific cell instead of the columns
 
Upvote 0
hi Guys,

I made it work this way

rivate Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$12" Then
Range("B12") = "ALL"

End If
End Sub
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal target As Range)
If target = Range("B2") Then
Worksheets("Sheet1").Range("C2").ClearContents
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,261
Messages
6,123,931
Members
449,134
Latest member
NickWBA

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