Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How do I use Workbooks.Add

Hi, I wanted to use Workbooks.Add to create a new, blank
output workbook but it always creates it with the default
3 sheets, how can I create it with just 1 sheet.
The finished Workbook will have more sheets added later in
the routine but the workbook will be used by others that
may have the default set to a different value

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How do I use Workbooks.Add

Try something like

Dim NewSheets As Integer
NewSheets = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = NewSheets


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


"Newboy18" wrote in message
...
Hi, I wanted to use Workbooks.Add to create a new, blank
output workbook but it always creates it with the default
3 sheets, how can I create it with just 1 sheet.
The finished Workbook will have more sheets added later in
the routine but the workbook will be used by others that
may have the default set to a different value



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How do I use Workbooks.Add

Thanks, that was the fastest reply I ever had.
Turns out that all I needed was the 1 line
Application.SheetsInNewWorkbook = 1

Then my
Workbooks.Add


-----Original Message-----
Try something like

Dim NewSheets As Integer
NewSheets = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = NewSheets


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


"Newboy18" wrote in

message
...
Hi, I wanted to use Workbooks.Add to create a new, blank
output workbook but it always creates it with the

default
3 sheets, how can I create it with just 1 sheet.
The finished Workbook will have more sheets added later

in
the routine but the workbook will be used by others that
may have the default set to a different value



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I use Workbooks.Add

The command sets the users options in Tools=Options to 1, so now whenever
they add a workbook, it will have 1 sheet. The reason Chip gave you the
additional lines of code was so you would reset the number of sheets back to
what the user originally had. Not using all the code would result in
extremely ill behaved code.

An easier way to do it without changing the users settings is:

Workbooks.Add xlWBATWorksheet

This will add a one sheet workbook.

--
Regards,
Tom Ogilvy

"Newboy18" wrote in message
...
Thanks, that was the fastest reply I ever had.
Turns out that all I needed was the 1 line
Application.SheetsInNewWorkbook = 1

Then my
Workbooks.Add


-----Original Message-----
Try something like

Dim NewSheets As Integer
NewSheets = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = NewSheets


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


"Newboy18" wrote in

message
...
Hi, I wanted to use Workbooks.Add to create a new, blank
output workbook but it always creates it with the

default
3 sheets, how can I create it with just 1 sheet.
The finished Workbook will have more sheets added later

in
the routine but the workbook will be used by others that
may have the default set to a different value



.



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
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM
suddenly my excel workbooks are "shared workbooks" Maggie's mom Excel Discussion (Misc queries) 1 August 28th 05 09:20 PM
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM


All times are GMT +1. The time now is 07:56 PM.

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

About Us

"It's about Microsoft Excel"