Hi
I have a Named Table "T_1" that follows the pattern below:
[TABLE="class: grid, width: 600, align: center"]
<tbody>[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD]Header1
[/TD]
[TD]Header2
[/TD]
[TD]Header3
[/TD]
[TD]Header4
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val1-a[/TD]
[TD]to empty when
val1-a
changes[/TD]
[TD]to empty when
val1-a
changes[/TD]
[TD]to empty when
val 1-a
changes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val2-a[/TD]
[TD]val2-a1[/TD]
[TD]to empty when
val2-b and/or
val2-b1
change(s)[/TD]
[TD]to empty when
val 2-b and/or
val2-b1
change(s)[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val3-a[/TD]
[TD]val3-a1[/TD]
[TD]val3-c2[/TD]
[TD]to empty when
val3-a and/or
val3-b and/or
val3-c
change(s)[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I am trying to do is to write the vba code that can delete the value of (turn empty) the cells in columns n+1, n+2 and n+3 (at most) if the value the active cell n is deleted.
The Table above is presenting the three cases that could occure in this example.
However, the Table, as it is, has 4 columns only and I might need to add columns and expand it.
I am trying, at this point to make it work with just the case of Val1-a but I am struggling...
Last piece of information: each of these cells are dynamic drop down lists which are linked to the adjacent left cell value, hence this code to avoid wrong inputs...
Can somebody help me figure out what is not right in the code and maybe help me to generalize it?
Thank you so much in advance.
Best Regards,
Shiro
I have a Named Table "T_1" that follows the pattern below:
[TABLE="class: grid, width: 600, align: center"]
<tbody>[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD]Header1
[/TD]
[TD]Header2
[/TD]
[TD]Header3
[/TD]
[TD]Header4
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val1-a[/TD]
[TD]to empty when
val1-a
changes[/TD]
[TD]to empty when
val1-a
changes[/TD]
[TD]to empty when
val 1-a
changes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val2-a[/TD]
[TD]val2-a1[/TD]
[TD]to empty when
val2-b and/or
val2-b1
change(s)[/TD]
[TD]to empty when
val 2-b and/or
val2-b1
change(s)[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD]Val3-a[/TD]
[TD]val3-a1[/TD]
[TD]val3-c2[/TD]
[TD]to empty when
val3-a and/or
val3-b and/or
val3-c
change(s)[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD]etc[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I am trying to do is to write the vba code that can delete the value of (turn empty) the cells in columns n+1, n+2 and n+3 (at most) if the value the active cell n is deleted.
The Table above is presenting the three cases that could occure in this example.
However, the Table, as it is, has 4 columns only and I might need to add columns and expand it.
I am trying, at this point to make it work with just the case of Val1-a but I am struggling...
Last piece of information: each of these cells are dynamic drop down lists which are linked to the adjacent left cell value, hence this code to avoid wrong inputs...

Can somebody help me figure out what is not right in the code and maybe help me to generalize it?
Thank you so much in advance.
Best Regards,
Shiro
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Cells(ActiveCell.Row, 7)) Is Nothing Then
Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row, ActiveCell.Column + 3)).ClearContents
End If
End Sub