assigning a workbook name

patl

Board Regular
Joined
Dec 15, 2005
Messages
123
is there a way to create a new workbook and assign it a name without saving it? I am trying to do this in a macro. Any advice is greatly appreciated
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
Something like?
Code:
Dim NewWorkBook As Workbook

Application.Workbooks.Add
Set NewWorkBook = ActiveWorkbook
 

patl

Board Regular
Joined
Dec 15, 2005
Messages
123
well, I would like to change the name of the new activeworkbook that was created as well. (from "sheet2" to something else). Is that possible?
 

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
patl said:
well, I would like to change the name of the new activeworkbook that was created as well. (from "sheet2" to something else). Is that possible?

Change the name of the workbook or worksheet? :unsure: If you're looking to change the name of the worksheet, use something like
Code:
ActiveSheet.Name = "Whatever"

Note - assumes the sheet that's active is the sheet you want to re-name.
 

patl

Board Regular
Joined
Dec 15, 2005
Messages
123

ADVERTISEMENT

change the name of the workbook. sorry i mean to say change from "book2" to something else.
 
L

Legacy 98055

Guest
The "Name" property for the "Workbook" object is read-only. There may be a work-around using the VBA extensibility library. Why do yo need to change it? If you created the workbook via code, you should already have a reference to it...
 

patl

Board Regular
Joined
Dec 15, 2005
Messages
123
well ultimately the user wont see the code so it is more of a clarity thing. So when the report spits out 3 new workbooks, they have descriptive names. But its not too big a deal. i can work around it. thanks.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,917
Messages
5,575,027
Members
412,635
Latest member
Arren
Top