deleting more than one page with macro's

S

shrek

Ive got a work book with 6 sheets of data in it. Ive worked out how t
delete each page indivudally. Im trying to find out how to delete th
data in all 6 sheets at once whilst still keeping the template that al
the data goes into. I use the assign macro using the tools on excel.


Can anyone help or point me in the right direction?

Im new to macro's so if a explination in idiot proof mode would b
greatly appriciate
 
R

Ron de Bruin

Hi

You can loop through all the sheets in the workbook
Try this on a copy of your workbook

You can use
sh.Cells.Clear (delete also the formating)
Or
sh.Cells.ClearContents

Sub test()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Cells.ClearContents
Next sh
End Sub

Copy this in a normal module

Alt-F11
Insert>Module from the menubar
paste the sub in there
Alt-Q to go back to Excel

If you do Alt-F8 you get a list of your macro's
Select "test" and press Run
 

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