ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Workbook with specific number of worksheets (https://www.excelbanter.com/excel-programming/300222-add-workbook-specific-number-worksheets.html)

Linda Mac

Add Workbook with specific number of worksheets
 
I want to do a Workbook.Add to add a new workbook and I
want it to have 4 worksheets in the workbook. How can I
force it to have 4 worksheets?

Bob Phillips[_6_]

Add Workbook with specific number of worksheets
 
Hi Linda,

It's not hard

Application.SheetsInNewWorkbook = 4
Workbooks.Add


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Linda Mac" wrote in message
...
I want to do a Workbook.Add to add a new workbook and I
want it to have 4 worksheets in the workbook. How can I
force it to have 4 worksheets?




Ron de Bruin

Add Workbook with specific number of worksheets
 
Hi linda

Try this

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



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


"Linda Mac" wrote in message ...
I want to do a Workbook.Add to add a new workbook and I
want it to have 4 worksheets in the workbook. How can I
force it to have 4 worksheets?




Tom Ogilvy

Add Workbook with specific number of worksheets
 
numSh = application.SheetsInNewWorkbook
application.SheetsInNewWorkbook = 4
Workbooks.Add
application.SheetsInNewWorkbook = numSh

--
Regards,
Tom Ogilvy

"Linda Mac" wrote in message
...
I want to do a Workbook.Add to add a new workbook and I
want it to have 4 worksheets in the workbook. How can I
force it to have 4 worksheets?




Ron de Bruin

Add Workbook with specific number of worksheets
 
You can remove the line Linda
Dim a As Integer


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


"Ron de Bruin" wrote in message ...
Hi linda

Try this

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



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


"Linda Mac" wrote in message ...
I want to do a Workbook.Add to add a new workbook and I
want it to have 4 worksheets in the workbook. How can I
force it to have 4 worksheets?







All times are GMT +1. The time now is 11:39 PM.

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