ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   delete command macro's (https://www.excelbanter.com/excel-worksheet-functions/49352-delete-command-macros.html)

shrek

delete command macro's
 

I have a workbook which has 4 files within it. At present I have macro's
set up to delete the data within each file seperately. Can anyone help
me so that I can use just one macro to delete all the data from the
workbooks on one command instead of deleting them seperately.

Many Thanks


--
shrek

jahoobob


shrek Wrote:
I have a workbook which has 4 files within it. At present I have macro's
set up to delete the data within each file seperately. Can anyone help
me so that I can use just one macro to delete all the data from the
workbooks on one command instead of deleting them seperately.

Many Thanks


I'm assuming you have one workbook with 4 worksheets that you want to
delete at on time. If so place this code in a macro:

Sub Macro1()
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet4").Select
ActiveWindow.SelectedSheets.Delete
End Sub

Run it and it should delete all the named sheets.
Hope this answers your question
Bob


--
jahoobob


All times are GMT +1. The time now is 12:28 AM.

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