Refer To Named Constant In VBA
-
-
-
-
Re: Refer To Named Constant In VBA
Thanks, that helps.
But now there's a different problem.
The value returned always contains an "=" and quotation marks. I would like it to return just [Bill] not [="Bill"]
I know I can strip them out, but is there a way to enter it into the Refers To so that they aren't there in the 1st place? -
-
Re: Refer To Named Constant In VBA
I have a related question: can a CONST refer to a cell value or named range?
I realize this violates the idea of a CONST, because the values could change, but could it be done and would there be any value in doing so as opposed to refering to a named range within a sub() procedure?
-
-
Re: Refer To Named Constant In VBA
Try hacking around with this:
Code
Display MoreSub ShowValueOfNamedConstant() 'Example how to use named formulas as named constants that can be changed without editing any VBA code Dim ValueOfNamedConstant As String Dim xNumber As Double ValueOfNamedConstant = Evaluate(ThisWorkbook.Names("myNamedConstant").RefersToR1C1) 'But do your own data type checking and conversion if necessary xNumber = ValueOfNamedConstant + 1.5 'must be a number to do this MsgBox ValueOfNamedConstant MsgBox xNumber MsgBox ValueOfNamedConstant & xNumber End Sub
Example values for the RefersTo in the name manager:
="String value"
=100.5
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!