ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorkBooks.add (https://www.excelbanter.com/excel-programming/302569-workbooks-add.html)

Excel and VBA user

WorkBooks.add
 
Is it possible to set how many sheets are in a workbook
when you use Workbooks.Add. Or can I set the sheetcount
without writing a loop to add the amount of sheets.

Ron de Bruin

WorkBooks.add
 
Hi

Try this

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


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


"Excel and VBA user" wrote in message ...
Is it possible to set how many sheets are in a workbook
when you use Workbooks.Add. Or can I set the sheetcount
without writing a loop to add the amount of sheets.




TommyGun

WorkBooks.add
 
Or, if you only want one worksheet, use this...Workbooks.Add(xlWorksheet)

"Ron de Bruin" wrote:

Hi

Try this

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


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


"Excel and VBA user" wrote in message ...
Is it possible to set how many sheets are in a workbook
when you use Workbooks.Add. Or can I set the sheetcount
without writing a loop to add the amount of sheets.





Ron de Bruin

WorkBooks.add
 
Or, if you only want one worksheet, use this...Workbooks.Add(xlWorksheet)

Or this

Workbooks.Add (1)
a higher number is not working

Or

Workbooks.Add (xlWBATWorksheet)


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


"TommyGun" wrote in message ...
Or, if you only want one worksheet, use this...Workbooks.Add(xlWorksheet)

"Ron de Bruin" wrote:

Hi

Try this

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


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


"Excel and VBA user" wrote in message ...
Is it possible to set how many sheets are in a workbook
when you use Workbooks.Add. Or can I set the sheetcount
without writing a loop to add the amount of sheets.








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

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