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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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