G
geoff_ness
I would like to be able to evaluate the value of the named constant
sSPEC_NAME in the active workbook by using application.evaluate, as
follows:
Dim vTest as Variant
vTest = Application.Evaluate("'" & Application.ActiveWorkbook.Name &
"'!" & sSPEC_NAME)
This works fine, except where ActiveWorkbook.Name contains a single
quote, which causes the string being evaluated to become nonsense. Can
anyone suggest an alternative approach?
The most obvious to me would be
vTest =
Application.Evaluate(Application.ActiveWorkbook.Names(sSPEC_NAME).RefersTo)
but the issue then is that this will raise a runtime error where there
is no constant named sSPEC_NAME in the active workbook. Ideally I
would be to escape the single quote somehow in the first approach - is
there a way to do this?
TIA
sSPEC_NAME in the active workbook by using application.evaluate, as
follows:
Dim vTest as Variant
vTest = Application.Evaluate("'" & Application.ActiveWorkbook.Name &
"'!" & sSPEC_NAME)
This works fine, except where ActiveWorkbook.Name contains a single
quote, which causes the string being evaluated to become nonsense. Can
anyone suggest an alternative approach?
The most obvious to me would be
vTest =
Application.Evaluate(Application.ActiveWorkbook.Names(sSPEC_NAME).RefersTo)
but the issue then is that this will raise a runtime error where there
is no constant named sSPEC_NAME in the active workbook. Ideally I
would be to escape the single quote somehow in the first approach - is
there a way to do this?
TIA