Insert named range problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to insert a named range using an A1 reference based on the
activecell using VBA. Based on Help, I tried the following code:

With ActiveWorkbook
.Names.Add Name:="Hold1", RefersTo:=RefersToLocal
End With
It does insert a name, but the range it refers to is #N/A. Is there a way
to do this so that it actually refers to the cell (for example, =B45)?
 
Hi FinChase,

Try:

RefersTo := ActiveCell

Or for any other cell just use, e.g.:
RefersTo := [B45]

-Erik
 
RefersToLocal is another property thatyiu could use rather than Refersto, if
the formula is in local language.

You need to rfefrence the range, but it can be shortcut with

Activecell.Name:="Hold1"

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
it aint that simple...

ReferstoLocal argument of the Names.Add method
does NOT accept local formulas...

it accepts local FUNCTIONS but needs USenglish
separators and references.
 
I think you are missing the point, it is not a value to the RefersTo
property as the OP was using it, it was being used as an (undefined)
variable. He doesn't want RefersToLocal AFAICS, he got confused by the help.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
true

my comment was more a NOTE to you <g>
stay away from the RefersTolocal/ReferstoR1c1Local
arguments of the names.add method.

they were programmed by a xenophobe.
 
Jurgen,

I can assure you that I do stay well away from it <vbg>.

One of the 'advantages' of using a version of MS products that is almost US
is that internatiolisation issues are rarely a problem, and when they are I
use my continental colleagues to sort it for me :-).

Bob
 

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

Back
Top