Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Sugestion for the Excel Guys

Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Sugestion for the Excel Guys

Well, you could do Workbooks.Add followed by the requisite number of
Worksheets.Add.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Sugestion for the Excel Guys

Yeah, but thats not very cool. Its like a WorkAround.
I was thinking something in the lines of class modules, which I am not very
familiar with.

"Jon Peltier" wrote:

Well, you could do Workbooks.Add followed by the requisite number of
Worksheets.Add.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sugestion for the Excel Guys

Hi Albert,

Why not simply change SheetsInNewWorkbook if you need to and reset as
original.

Sub test()
Dim wbNew As Workbook

AddNewBook wbNew, 6

MsgBox wbNew.Worksheets.Count & " worksheets", , wbNew.Name

End Sub

Sub AddNewBook(wb As Workbook, Optional nSheets As Long = 0)
Dim nSheetsDefault As Long

On Error GoTo errExit
If nSheets 0 Then
nSheetsDefault = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = nSheets
End If

Set wb = Application.Workbooks.Add

errExit:
If nSheetsDefault 0 Then
Application.SheetsInNewWorkbook = nSheetsDefault
End If
End Sub

Regards,
Peter T
"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Sugestion for the Excel Guys

Half of programming in Excel is a workaround.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Albert" wrote in message
...
Yeah, but thats not very cool. Its like a WorkAround.
I was thinking something in the lines of class modules, which I am not
very
familiar with.

"Jon Peltier" wrote:

Well, you could do Workbooks.Add followed by the requisite number of
Worksheets.Add.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments
for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sugestion for the Excel Guys

Hi John,

Your suggestion and example code seems pretty much the same as I had posted
earlier, except it omits to trap user's original application setting and
resets to a notional SheetsInNewWorkbook = 3

I know '3' is Excel's default install but users can and do change this in
Tools Options General, not infrequently to '1' and no doubt to other
values.

Regards,
Peter T

"John Bundy" wrote in message
...
Or the easy way, change it to what you want then change it back:

On Error Resume Next
Application.SheetsInNewWorkbook = 16
Application.Workbooks.Add
Application.SheetsInNewWorkbook = 3

-John

"Albert" wrote:

Very cool stuff sir.
Thanx!

"Peter T" wrote:

Hi Albert,

Why not simply change SheetsInNewWorkbook if you need to and reset as
original.

Sub test()
Dim wbNew As Workbook

AddNewBook wbNew, 6

MsgBox wbNew.Worksheets.Count & " worksheets", , wbNew.Name

End Sub

Sub AddNewBook(wb As Workbook, Optional nSheets As Long = 0)
Dim nSheetsDefault As Long

On Error GoTo errExit
If nSheets 0 Then
nSheetsDefault = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = nSheets
End If

Set wb = Application.Workbooks.Add

errExit:
If nSheetsDefault 0 Then
Application.SheetsInNewWorkbook = nSheetsDefault
End If
End Sub

Regards,
Peter T
"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the

arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C





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
Thanks Guys J.Mart[_2_] Excel Discussion (Misc queries) 2 December 11th 07 01:09 PM
another excel question, thanks guys! brandon roland[_2_] Excel Discussion (Misc queries) 4 August 3rd 07 08:14 PM
Please Help Guys! ivanov_nv Excel Worksheet Functions 2 November 9th 04 03:50 PM
Help needed guys!!!!, Excel macro eakin Excel Programming 1 November 2nd 04 01:55 PM
Hey guys, Momo Excel Programming 0 October 22nd 04 03:47 PM


All times are GMT +1. The time now is 03:36 PM.

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"