Name a range using cell contents

S

SB_2009

I want to setup a macro for users to define named ranges in several sheets
and name the range whatver they enter into a certain cell in that sheet e.g:

Range("B15:K15").Select
ActiveWorkbook.Names.Add Name:="_1A", RefersToR1C1:= _
"=TEMPLATE!R15C2:R15C11"
Where "_1A" is the user entry into a specific cell which will be the same
cell in each sheet. When i record the macro it puts in "_1A" each time - how
do i get it to link to the variable cell contents?

Thanks,
 
G

Gary''s Student

Say we have "alpha" in cell A1.

Range("B15:K15").Select
ActiveWorkbook.Names.Add Name:=Range("A1").Value, RefersToR1C1:= _
"=Sheet1!R15C2:R15C11"

will use alpha for the Name
 
S

SB_2009

That works brilliantly however this has brought up another problem -when i
copy the sheet and rename and then run the macro it refers to the cell range
in the original sheet when i copy the sheet. Is there a way of referring to
the cell range in the active worksheet?

SB
 

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