Determining if a worksheet exists within a workbook
Hi.
Sub AddWkbOneSheet()
Workbooks.Add xlWBATWorksheet
End Sub
Sub AddWkbFiveSheets()
Dim Exnb As Long
Exnb = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 5
Workbooks.Add
Application.SheetsInNewWorkbook = Exnb
End Sub
Alain CROS.
-----Original Message-----
I have a macro that creates a new excel workbook and adds
a variable
number of new worksheets to the new workbook.
I would like to delete any excess worksheets from this
newly created
workbook (ie: Default "Sheet1", "Sheet2", "Sheet3"). I
can add code
to delete these sheets:
Sheets("Sheet1").Delete
Sheets("Sheet2").Delete etc...
but, the number of sheets added to a new excel workbook
will vary
depending on the individual user's Excel defaults.
1. Is there a way to determine if a sheet exists, and if
it does,
delete it, ie:
If Sheets("Sheet1").Exists then Delete Sheets("Sheet1").
2. Is there a way to within a macro force a new workbook
to open with
a set number of sheets?
Any help would be appreciated!
Thanks,
Cory
.
|