Refers to active cells

M

Miree

I have this line of code is there a way to change the RefersTo section to
ReferTo the active cells?

ActiveWorkbook.Names.Add Name:="OBM", RefersToR1C1:="=Densities!R4C6:R139C6"

Thank you
 
P

Per Jessen

Hi

This should do it:

MyList = Selection.Address
ActiveWorkbook.Names.Add Name:="OBM", RefersTo:="=Densities!" & MyList

Regards,
Per
 
P

papou

Hi
The answer is Yes:
ActiveWorkbook.Names.Add Name:="OBM", RefersToR1C1:=Selection.Address

But I would be careful about that.

HTH
Cordially
Pascal
 
P

papou

Since active cells could be from another sheet:
shname = ActiveSheet.Name & "!"
ActiveWorkbook.Names.Add Name:="OBM", RefersToR1C1:=shname &
Selection.Address

But I still think this is a little dangerous.

HTH
Cordially
Pascal
 
M

Miree

This worked well, but came accross a problem, one of the ranges i need
defined is a combination of two ranges WBM and OBM, is there a way to make
both named ranges active and to name?

Thank you
 
M

Miree

That doesn't work when you need to select two named ranges, but i have
decided i dont need it anymore anyways but thatnks for all the advice
 
D

Dave Peterson

Another:

with selection
.name = "'" & .parent.name & "'!" & "OBM"
end with

Ps. I wouldn't use this name.

If you ever upgrade to xl2007 (with 16k columns), this will be an invalid
name--it looks too much like a column reference.

I'd use "_OBM"
 

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