Creating named range in VBA problem

B

Billy B

I have created the following line of code in the Workbook_Open event of a
workbook:

Application.Names.Add Name:="FormatTempITC105",
RefersTo:="FormatLine!$A$30:$IA$30"

After I open the workbook, if I check for the named range in the
Insert/Names/Defines, the name exists. If I look in the Name Box, it is not
listed.

The problem I have is that, if the named range is being created by the
Workbook_Open event, I get an error in the worksheet code using the name
range above. If I don't put the code in the Workbook_Open and create the
named range from the Insert/Name/Define, the worksheet code runs fine.

Is there something I am missing when creating the named range in the
Workbook_Open event code?
 
B

Billy B

The formula you gave me did not work. After careful study I found out why
neither of ours worked: There needs to be an = in the named range:

worksheets("formatline").Range("A30:AI30").Name :="=FormatTempITC105"
 
P

Patrick Molloy

my error - qa typo

I wrote
worksheets("formatline").Range("A30:AI30").Name :="FormatTempITC105"

instead of
worksheets("formatline").Range("A30:AI30").Name ="FormatTempITC105"
 

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