Clearing Adjacent cells data

Don Fardie

New Member
Joined
Aug 6, 2014
Messages
23
Hi ....New to VBA’s and I assume that what is needed to ClearCell content. I have data being added to cell ranges K16:K34. Based on theinput entered into those cells (selection is based of a Data Validation list)the information in the adjacent cells L16:L34, M16:M34, N16:N34 can then beselected (those too are Data Validation Lists, based on what was first enteredinto the K16:K34 cells. <o:p></o:p>
What I want to do if the cells are cleared or a newselection is selected in The K range cells, the adjacent cells to them will automaticallyclear the previous data. Any help is appreciated ….Thanks Don<o:p></o:p>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
try this change event
Right click on the tab you want the code to run on.
Select view code
Paste the code below into the VBA editor.
The file must be saved as a macro enabled file type such as .XLSM

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("K16:K34")) Is Nothing Then
    Range("L" & Target.Row & ":N" & Target.Row).ClearContents
End If
 Application.EnableEvents = True
End Sub
 
Upvote 0
You the Man Scott....worked like a charm. If I wanted to extend the column range to say clear to the R column, all I would do is change the :N" to :R"
Thanks again!!!
 
Upvote 0
You're Welcome.

Yes If you want to clear L to R then you would change the :N to an :R.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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