clear cells on change of another cell via VB

asylum

Board Regular
Joined
Dec 2, 2003
Messages
243
HI,

On Sheet one i have cell a1, which is a picklist of dates. When this changes value I woudl like to clear the contents of teh cells in range a1:d90 in sheet2, what would be a good way of doing this via VB?

Thanks

Andy
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this: right click Sheet1's tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then Sheets("Sheet2").Range("A1:D90").ClearContents
End Sub
 
Upvote 0
Thats great thanks, how would I modifiy it if I wante dthe same action if any cell in range a1:d40 on sheet1 happend?

CHeers

Andy
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1:D40")) Is Nothing Then Sheets("Sheet2").Range("A1:D90").ClearContents
End Sub
 
Upvote 0
HI, that did the trick very well, thanks, I stacked up a few conditions and it acted just as i wnated, many thanks
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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