» Create new workbooks using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Files, Workbook, and Worksheets in VBA
VERSION - All Microsoft Excel Versions
You can use the macro like this if you want to create a new workbook with 10 worksheets:
Set wb = NewWorkbook(10)
Function NewWorkbook(wsCount As Integer) As Workbook
' creates a new workbook with wsCount (1 to 255) worksheets
Dim OriginalWorksheetCount As Long
Set NewWorkbook = Nothing
If wsCount < 1 Or wsCount > 255 Then Exit Function
OriginalWorksheetCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = wsCount
Set NewWorkbook = Workbooks.Add
Application.SheetsInNewWorkbook = OriginalWorksheetCount
End Function
Book Store:
Recommended Books:
- The Intelligent Investor: The Classic Bestseller on Value Investing
- H&R Block's Just Plain Smart(tm) Tax Planning Advisor: A year-round approach to lowering your taxes this year, next year and beyond
- Writing Excel Macros with VBA, 2nd Edition
- The Sweet Potato Queens' Big-Ass Cookbook and Financial Planner
- Fish! A Remarkable Way to Boost Morale and Improve Results
- Business Plans Kit for Dummies (With CD-ROM)
No comments have been submitted.


