Create and Name new workbook

melewie

Board Regular
Joined
Nov 21, 2008
Messages
188
Office Version
  1. 365
Platform
  1. Windows
Hello All :)

I am having problems trying to write a peice of code that will create a new work book and name it. The problem im having is that the user will likely do this several times, what I would like to do is....

New WB = "Raw Data" if WB Raw Data already exists then new WB = "Raw Data 1" and so on.... I can do this by creating a neverending if statement, is there a better way to do this??

Any help would be great - Thanks
 
I do not believe you can rename an unsaved/new workbook, as I believe the name is read-only at that point.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Nearly there... what's your current code for creating a new workbook and naming it "RAW DATA"?

I can't seem to create a new workbook and have it called anything other than "Book1".
 
Upvote 0
Nearly there... what's your current code for creating a new workbook and naming it "RAW DATA"?

I can't seem to create a new workbook and have it called anything other than "Book1".

:confused: :confused: Seems you cant do that either! I hadnt tried just presumed it would be something like
Code:
Set NewBook = Workbooks.Add
    With NewBook
        .Title = "Raw Data"
        .Subject = "Data"
    End With

But I guess this really isnt possible :mad:
 
Last edited:
Upvote 0
After much Googlification I've come to the conclusion that you can't change the name of a workbook unless you save it first.

Maybe you could save the workbook in the user's TEMP directory as soon as you create it. You could still allow the user to save it in a location of their choosing and use the Before_Save event to delete the one in TEMP.

Apart from that I'm all out of ideas.
 
Upvote 0
Thanks for your help with this - I have come to the same conclusion. think I will just leave it as book x and refrence it when its created.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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