Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default # of sheets in a new workbook

When you programmatically add a new workbook, is it possible to indicate the
number of sheets the new workbook should have?

Thanks for the help.......
--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default # of sheets in a new workbook

JT,

Try something like

Application.SheetsInNewWorkbook = 4


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"JT" wrote in message
...
When you programmatically add a new workbook, is it possible to
indicate the
number of sheets the new workbook should have?

Thanks for the help.......
--
JT



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default # of sheets in a new workbook

Hi JT

Try this

Sub test()
Dim OldValue As Integer
OldValue = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 6
Workbooks.Add
Application.SheetsInNewWorkbook = OldValue
End Sub


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


"JT" wrote in message ...
When you programmatically add a new workbook, is it possible to indicate the
number of sheets the new workbook should have?

Thanks for the help.......
--
JT



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default # of sheets in a new workbook

Here is some code...

Sub test()
Dim wbk As Workbook
Dim intSheets As Integer
On Error GoTo Errorhandler

intSheets = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 4
Set wbk = Workbooks.Add
Errorhandler:
Application.SheetsInNewWorkbook = intSheets
End Sub

As always when changing application level settings it is best to use an
error handler
--
HTH...

Jim Thomlinson


"JT" wrote:

When you programmatically add a new workbook, is it possible to indicate the
number of sheets the new workbook should have?

Thanks for the help.......
--
JT

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default # of sheets in a new workbook

Another option...

You can add a workbook with just one sheet and add as many as you want later.

dim newWkbk as workbook
dim iCtr as long
set newwkbk = workbooks.add(1)
for ictr = 1 to 99
newwkbk.worksheets.add
next ictr

I'd end up with 100 worksheets in that new workbook.

JT wrote:

When you programmatically add a new workbook, is it possible to indicate the
number of sheets the new workbook should have?

Thanks for the help.......
--
JT


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
add new sheets in a workbook with new sheets being a variable [email protected] Excel Discussion (Misc queries) 1 April 11th 06 08:38 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
Create New Workbook - Name book - 4 Sheets - Name Sheets Greg[_21_] Excel Programming 6 June 12th 05 04:41 AM
Sheets select method fails when workbook is opened by another workbook Mike Excel Programming 2 June 8th 04 04:17 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"