Clear Contents of all Sheets

T

timmie7004

How would I clear the contents of all Sheets in my file? I can record
a macro that will clear the contents of a specific, but I have
multiple sheets and was wondering if there is a nice easy way

Newbie here

Thanks

Timmie
 
M

Mike H

Hi,

If you going to do that why not simply delete the workbook. But if you want
another method use this. BEWARE it will delete everything so make sure thats
what you want. Alt+Fll to open Vb editor. Right click a worksheet tab, view
code and psate this in.

Sub clearall()
Dim ws As Worksheet
For x = 1 To ThisWorkbook.Worksheets.Count
Worksheets(x).UsedRange.ClearContents
Next
End Sub

Mike
 
T

timmie7004

Thank you Mike that works a dream. Didn't want to delete the
worksheets as I have formats setup, so each week I copy in different
data (but require the same formats)

Tim
 
D

Dana DeLouis

Once your workbook is clear, see if saving your workbook as a "Template"
might be an option for you.
 
M

Mike H

Hi,

Glad that helped and thanks for the feedback. BTW my response was a cut from
another sub and I included this line which isn't necessary
Dim ws As Worksheet

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top