» 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:
- What the IRS Doesn't Want You to Know: A Cpa Reveals the Tricks of the Trade
- Microsoft Access 2002 for Dummies
- Marketing Management
- Financial Statements: A Step-By-Step Guide to Understanding and Creating Financial Reports
- Lower Your Taxes - Big Time! : Wealth-Building, Tax Reduction Secrets from an IRS Insider
- Excel 2002 Power Programming with VBA
No comments have been submitted.

