VBA Worksheet_Change dependent validation reset dependents to blank

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Dear All,

If cell in column P then set Q and R to blank for relevent row in Column Q and R.

If Change in Column Q then set R to blank for relevent row in R.

Range name Master refers to Parent -Highest Level
Range Name UseList to Child - Middle Level

I have code below but it does not work.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
    If Not Intersect(Target, Range("Master")) Is Nothing Then
        Range(Cells(Target.Row, "Q"), Cells(Target.Row, "R")).Value = ""
    'Asset Type Changes
    ElseIf Not Intersect(Target, Range("UseList")) Is Nothing Then
        Range(Cells(Target.Row, "R")).Value = ""
    End If
Application.EnableEvents = True
End Sub

Your help would be appreciated.

Biz
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I have changed vba now look at current column in change

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Asset Group Changes
    If Not Intersect(Target.Row, Range("tP")) Is Nothing Then
        Range(Cells(Target.Row, "Q"), Cells(Target.Row, "R")).Value = ""
    'Asset Type Changes
    ElseIf Not Intersect(Target.Row, Range("tQ")) Is Nothing Then
        Range(Cells(Target.Row, "R")).Value = ""
    End If
End Sub

Still it does not work. Any suggestion?
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,258
Members
452,901
Latest member
LisaGo

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