ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Activecell.Address when defining name (https://www.excelbanter.com/excel-programming/309761-using-activecell-address-when-defining-name.html)

Hardy[_8_]

Using Activecell.Address when defining name
 
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


---
Message posted from http://www.ExcelForum.com/


Norman Jones

Using Activecell.Address when defining name
 
Hi Hardy,

Try:

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


---
Regards,
Norman



"Hardy " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Using Activecell.Address when defining name
 

Use Address instead of Addresslocal

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

VBA/Excel should make the necessary adjustments.

or

ActiveCell.Name = sNameString

--
Regards,
Tom Ogilvy


"Hardy " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Using Activecell.Address when defining name
 
the first should be:

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

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...

Use Address instead of Addresslocal

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

VBA/Excel should make the necessary adjustments.

or

ActiveCell.Name = sNameString

--
Regards,
Tom Ogilvy


"Hardy " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/






Hardy[_9_]

Using Activecell.Address when defining name
 
Thanks Norma and Tom!
Both work fin

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com