ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming Workbooks and Sheets (https://www.excelbanter.com/excel-programming/292050-naming-workbooks-sheets.html)

mike

Naming Workbooks and Sheets
 
I need to insert a new workbook that is named from a cell
value plus a contstant.

I have done this with inserting worksheets like this:

Sheets.Add.Name = Range("B2").Value

What I want is something like

Workbooks.Add.Name = Range("B2") & "constant".Value

Is there a different syntax for workbooks and worksheets?

If so I would like to see both.

I have a tool that I want to keep clean so when the user
is finished entering data I am taking that information
and storing it in a new workbook named from a value in
the tool and then inserting 2 worksheets named for the
value + contstant. The constant is obviously unique for
each page.

Thanks

Mike

Chip Pearson

Naming Workbooks and Sheets
 
Mike,

The Name of a workbook is the filename as which it was saved.
Therefore, you want to use code like

Workbooks.Add.SaveAs Filename:=Range("A1").Text



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Mike" wrote in message
...
I need to insert a new workbook that is named from a cell
value plus a contstant.

I have done this with inserting worksheets like this:

Sheets.Add.Name = Range("B2").Value

What I want is something like

Workbooks.Add.Name = Range("B2") & "constant".Value

Is there a different syntax for workbooks and worksheets?

If so I would like to see both.

I have a tool that I want to keep clean so when the user
is finished entering data I am taking that information
and storing it in a new workbook named from a value in
the tool and then inserting 2 worksheets named for the
value + contstant. The constant is obviously unique for
each page.

Thanks

Mike




JE McGimpsey

Naming Workbooks and Sheets
 
Workbooks are given their name when they're saved, so you can use


Workbooks.Add.SaveAs FileName:=Range("B2").Value & constant



In article ,
"Mike" wrote:

I need to insert a new workbook that is named from a cell
value plus a contstant.

I have done this with inserting worksheets like this:

Sheets.Add.Name = Range("B2").Value

What I want is something like

Workbooks.Add.Name = Range("B2") & "constant".Value

Is there a different syntax for workbooks and worksheets?

If so I would like to see both.

I have a tool that I want to keep clean so when the user
is finished entering data I am taking that information
and storing it in a new workbook named from a value in
the tool and then inserting 2 worksheets named for the
value + contstant. The constant is obviously unique for
each page.

Thanks

Mike



All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com