ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   deleting more than one page with macro's (https://www.excelbanter.com/excel-worksheet-functions/38002-deleting-more-than-one-page-macros.html)

shrek

deleting more than one page with macro's
 
Ive got a work book with 6 sheets of data in it. Ive worked out how to delete each page indivudally. Im trying to find out how to delete the data in all 6 sheets at once whilst still keeping the template that all 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 be greatly appriciated

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
InsertModule 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



--
Regards Ron de Bruin
http://www.rondebruin.nl


"shrek" wrote in message ...

Ive got a work book with 6 sheets of data in it. Ive worked out how to
delete each page indivudally. Im trying to find out how to delete the
data in all 6 sheets at once whilst still keeping the template that all
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 be
greatly appriciated


--
shrek





All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com