View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cory Schneider Cory Schneider is offline
external usenet poster
 
Posts: 1
Default Determining if a worksheet exists within a workbook

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