Carry range names into copy of template

G

Guest

I have a template with named ranges. I want to use VBA to copy the template
into another workbook and have the names of the ranges carried into the new
workbook. I can get the template into the new workbook, but none of the
ranges are named.

Any ideas?

Thank you for the assistance.

Don
 
G

Guest

i dont understand why you want to copy it to a new workbook.If you open a
true template ie an xlt file it always opens as a new copy of itself
use
Workbooks.Add Template:=
not
Workbooks.Open Filename:=
 
G

Guest

The template is one sheet. I want to insert it as a sheet in a multi sheet
workbook not open it as a separate workbook or separate template.
 
D

Dave Peterson

How are you getting the template to the new workbook?

Are you opening the template workbook, then copying the worksheet (not the
cells, but the worksheet), then closing the template?

I think that would work.

And if you just want to add a new sheet based on a template to an existing
workbook:

Option Explicit
Sub testme()
Dim newWks As Object
Set newWks = Sheets.Add(Type:="C:\my documents\excel\book1.xlt")
End Sub


I think if I were doing this, I'd make sure those names were sheet level
names--not workbook level names.

Insert|Name|Define
Names in Workbook: Sheet1!myNameHere
Refers to: =Sheet1!$C$6:$G$15

Then I could add the sheet as many times as I want and not have to worry about
name conflicts.

======
And if you're working with names, get a copy of Jan Karel Pieterse's (with
Charles Williams and Matthew Henson)
Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

You'll be very happy you did.
 
G

Guest

Thank you, Dave. Problem solved.

Don

Dave Peterson said:
How are you getting the template to the new workbook?

Are you opening the template workbook, then copying the worksheet (not the
cells, but the worksheet), then closing the template?

I think that would work.

And if you just want to add a new sheet based on a template to an existing
workbook:

Option Explicit
Sub testme()
Dim newWks As Object
Set newWks = Sheets.Add(Type:="C:\my documents\excel\book1.xlt")
End Sub


I think if I were doing this, I'd make sure those names were sheet level
names--not workbook level names.

Insert|Name|Define
Names in Workbook: Sheet1!myNameHere
Refers to: =Sheet1!$C$6:$G$15

Then I could add the sheet as many times as I want and not have to worry about
name conflicts.

======
And if you're working with names, get a copy of Jan Karel Pieterse's (with
Charles Williams and Matthew Henson)
Name Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

You'll be very happy you did.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top