Clear Sheet1 on closing Workbook

Dougie1

Board Regular
Joined
Jul 27, 2007
Messages
212
Good Morning All,

After some help here if possible.

Using Excel 2016.

I have data on Sheet1 (sheet is actually named “Master Data Sheet”).

What I would like to do is clear this sheet on closing the Workbook – except for Row A – which I would like to remain as it contains Header data.

Can anyone help please?

Thanks in advance.

D1
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
except for Row A

Hi, assuming you mean row 1 (A refers to a column) you could try this in the ThisWorkbook module:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Master Data Sheet").UsedRange.Offset(1).ClearContents
End Sub
 
Upvote 0
thanx FormR (yeah I did mean row 1 not row A!)

I will try this code on my workbook when I get home.

Thanks again for your help
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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