Naming Workbooks and Sheets

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

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
 
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
 
Workbooks are given their name when they're saved, so you can use


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