ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting CONST referencing a cell Value (https://www.excelbanter.com/excel-programming/380485-setting-const-referencing-cell-value.html)

JMay

Setting CONST referencing a cell Value
 
I've been trying to enter

CONST celladdress as STRING = sheets("mysetup").Range("E13").value

' E13 on my sheet mysetup contains the value "G1" (without the
quotes)

I'can't seem to accomplish this. Am I doing something wrong?

TIA,

Jim


Norman Jones

Setting CONST referencing a cell Value
 
Hi Jim,

You can only assign a constant value to a Constant.

You could use:
Const sStr As String = "A"

But you cannot use:
Const sStr2 As String = Range("A1").Value
'or
Const sStr As String = Chr(65)

Try instead:

Dim cellAddress As String

cellAddress = Sheets("mysetup").Range("E13").Value


---
Regards,
Norman


"JMay" wrote in message ...
I've been trying to enter

CONST celladdress as STRING = sheets("mysetup").Range("E13").value

' E13 on my sheet mysetup contains the value "G1" (without the quotes)

I'can't seem to accomplish this. Am I doing something wrong?

TIA,

Jim




JMay

Setting CONST referencing a cell Value
 
Thanks Norman;

Seems like a small price to pay by using:

Dim cellAddress As String
cellAddress = Sheets("mysetup").Range("E13").Value

Thanks,

Jim May

"Norman Jones" wrote:

Hi Jim,

You can only assign a constant value to a Constant.

You could use:
Const sStr As String = "A"

But you cannot use:
Const sStr2 As String = Range("A1").Value
'or
Const sStr As String = Chr(65)

Try instead:

Dim cellAddress As String

cellAddress = Sheets("mysetup").Range("E13").Value


---
Regards,
Norman


"JMay" wrote in message ...
I've been trying to enter

CONST celladdress as STRING = sheets("mysetup").Range("E13").value

' E13 on my sheet mysetup contains the value "G1" (without the quotes)

I'can't seem to accomplish this. Am I doing something wrong?

TIA,

Jim






All times are GMT +1. The time now is 12:26 AM.

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