Empty cell values when another cell value changes in Table environment

Shiro26

Board Regular
Joined
Oct 2, 2015
Messages
82
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


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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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