What are the default number of sheets created by Workbooks.Add???

AlexB123

Board Regular
Joined
Dec 19, 2014
Messages
207
Hi all,

I was re-writing an old macro, and I needed to create a workbook with 11 sheets. So I set Application.SheetsInNewWorkbook = 11.

This worked, but I noticed every computer that macro runs on now creates new workbooks with 11 sheets ...

I need to figure out the correct number of sheets to set the property back correctly, before I wreck havoc on the many macros that call Workbooks.Add.

Any help is appreciated!
 
Shouldn't your code say Count:=Nwksht - Worksheets.Count instead of - 1?

Oh, I get it. You're adding the worksheets, and maybe adding too many, then removing the excess in the next step. I didn't read your whole procedure very closely.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
The only downside to using the xlWBATWorksheet constant, but it is just a minor one, is that it names the new workbooks as Sheet1, Sheet2, etc. as you add successive new workbooks which is kind of unconventional for workbook names.

What bothers me is the way the sheet names (codenames) in the VB project get out of sync with the sheet names in Excel.

Start with Sheet1 in Excel. The sheet's codename is also Sheet1.

Add two sheets in Excel, Sheet2 and Sheet3. Their codenames are Sheet2 and Sheet3.

Delete Sheet2 in Excel, and Sheet2 is also gone from the project.

Add another sheet in Excel. It's Sheet4, but its codename is Sheet2.
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,669
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top