Can I open a blank workbook (VBA)?

MartinS

Active Member
Joined
Jun 17, 2003
Messages
489
Office Version
  1. 365
Platform
  1. Windows
Hi
Is it possible to open a blank workbook (i.e. no worksheets) then add to that a blank worksheet onto which I can copy/paste my stuff?
Each time I try it, it opens a workboo with three blank worksheets (as set in my options) - what I'd like is to only have the number of sheets required in my workbook - is this possible, or is is just a case of deleting the sheets before closing?
The code I use is:

Private wkbTWB As Workbook, wkbNEWWB As Workbook
Private wksNEWWS As Worksheet

'Define current workbook object...
Set wkbTWB = ThisWorkbook
'Add new workbook object...
Set wkbNEWWB = Workbooks.Add
'Add new worksheet object...
Set wksNEWWS = wkbNEWWB.Worksheets.Add

Any help/advice gratefully received
Regards
Martin
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Martin

What exactly are you copying?

The following code will create a workbook with only 1 sheet.
Code:
Workbooks.Add xlWBATWorksheet
 
Upvote 0
How about:

Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = 3
 
Upvote 0
I'm actually creating a 'report' based on parameters and data used in a spreadsheet (for checking purposes). The first sheet contains a copy of the parameters used, and the second the data and a few columns of calcs pertaining to that data. The copying is working fine, I just didn't want to save a workbook with more sheets than necessary.
Both suggestions will do the trick I guess, all I need to do is remove the worksheets add from the first process and write directly to the existing sheet.
Thanks guys
Regards
Martin
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,148
Members
452,547
Latest member
Schilling

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top