Using Activecell.Address when defining name

  • Thread starter Thread starter Hardy
  • Start date Start date
H

Hardy

Hi,

When using
ActiveWorkbook.Names.Add Name:=sNameString,
RefersTo:=ActiveCell.AddressLocal

To put the name stored in sNameString to the active cell, it does not
work because ActiveCell.Addreslocal returns "$B$2" rather than $B$2.
What is the easiest way around this?

Thanks
 
Hi Hardy,

Try:

ActiveWorkbook.Names.Add Name:=sNameString, _
RefersTo:=ActiveCell
 
Use Address instead of Addresslocal

ActiveWorkbook.Names.Add Name:=sNameString, _
RefersTo:="=" & ActiveCell.Address

VBA/Excel should make the necessary adjustments.

or

ActiveCell.Name = sNameString
 
the first should be:

ActiveWorkbook.Names.Add Name:=sNameString, _
RefersTo:="=" & ActiveCell.Address(external:=True)

--
Regards,
Tom Ogilvy


Tom Ogilvy said:
Use Address instead of Addresslocal

ActiveWorkbook.Names.Add Name:=sNameString, _
RefersTo:="=" & ActiveCell.Address

VBA/Excel should make the necessary adjustments.

or

ActiveCell.Name = sNameString
 

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