Retrieving Values Saved in Names
i was aware, but wasn't sure what was asked. thanks for pointing out the
difference
--
Gary
"Tom Ogilvy" wrote in message
...
The OP said:
How do I do the same thing when I stored a value directly in the Name?
Maybe you aren't aware you can do this, but is isn't a range - it is a
value.
Let's look in the immediate window:
Names.Add Name:="ABCD", Refersto:="=49"
? Names("ABCD").RefersTo
=49
nm = "ABCD"
? range(nm).Value
**** Big 1004 Error *****
? Evaluate(Activeworkbook.Names(nm).Refersto)
49
See the difference?
--
Regards,
Tom Ogilvyl
"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
i don't see any difference in what i posted
Range(nm).Value
gives the same result as
Evaluate(Activeworkbook.Names("MyName").Refersto)
--
Gary
"Tom Ogilvy" wrote in message
...
v = Evaluate(Activeworkbook.Names("MyName").Refersto)
should give you your 49.
of couse you can to
v = clng(Replace(ActiveWorkbook.Names("MyName").Refers to,"=",""))
--
Regards,
Tom Ogivy
"Steve Drenker" wrote in message
.. .
I just put this together. You pass the function the name of the stored
constant. It returns the value of the stored constant. Still seems like
a
kludge to me, but it works. I must be missing something here.
Function GetConst(ConstName As String) As String
Dim n As Name
For Each n In ActiveWorkbook.Names
If n.Name = ConstName Then
GetConst = Mid(n.RefersTo, 2) ' Strips off leading "="
Exit Function
End If
Next n
End Function
Sub TestGetConst()
Dim str As String
Debug.Print GetConst("Base_Year")
End Sub
in article , Gary Keramidas at
GKeramidasATmsn.com wrote on 3/3/06 6:36 PM:
i use this to create code to replicate the names from one sheet to
another,
but
i'm not sure what you want
Sub test5() ' use this one to update ranges
Dim nm As Name
sName = ActiveSheet.Name
For Each nm In ThisWorkbook.Names
Debug.Print "ActiveWorkbook.Names.Add Name:=" & """" & sName &
Right(nm.Name, Len(nm.Name) - 3) & """" & _
", Refersto:=""" & "=" & sName & "!" & Range(nm).Address & """"
'& """ & """ = """ & Range(nm).Address & ""
Next nm
End Sub
|