ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a Varible inside of a proper address (https://www.excelbanter.com/excel-programming/286362-using-varible-inside-proper-address.html)

[email protected]

Using a Varible inside of a proper address
 
Top of the morning

Assume the following:
LogSheet being a definied string variable
LogSheet has the value of 'Feb' assinged to it

It is used in the following line of code

ActiveWorkbook.Names.Add Name:="count",
RefersToR1C1:="=LogSheet!R8C7"

The code runs

I want Feb!r8c7.....I get LogSheetr8c7

Thanks in advance for any help

TerryK[_2_]

Using a Varible inside of a proper address
 
Try this
ActiveWorkbook.Names.Add Name:="count",
RefersToR1C1:="=" & LogSheet & "!R8C7"

If this does not work you may have to sent the string to a variable first
x= "=" & LogSheet & "!R8C7"
then
ActiveWorkbook.Names.Add Name:="count",
RefersToR1C1:= x

TerryK

No Name

Using a Varible inside of a proper address
 
Thanks for the solution....worked liked a charm

-----Original Message-----
Try this
ActiveWorkbook.Names.Add Name:="count",
RefersToR1C1:="=" & LogSheet & "!R8C7"

If this does not work you may have to sent the string to

a variable first
x= "=" & LogSheet & "!R8C7"
then
ActiveWorkbook.Names.Add Name:="count",
RefersToR1C1:= x

TerryK
.



All times are GMT +1. The time now is 09:41 PM.

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