View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Retrieving Values Saved in Names

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

--


Gary


"Steve Drenker" wrote in message
.. .
Not too much help, Gary. This is what I said I knew in my original message.
I suppose I could iterate across all names looking for the known name, then
pull out the value for that name. Sure does seem like a kludge, however.
There must be a better way.

Steve

in article , Gary Keramidas at
GKeramidasATmsn.com wrote on 3/3/06 6:00 PM:

maybe this will help
in the vb editor, click view and then immediate window and then execute this
code
you should see the range name, the address of the range and the value in the
cell
if the range has multiple cells, you won't get a value

Sub name_ranges3()
on error resume next
Dim nm As Name
For Each nm In ThisWorkbook.Names
Debug.Print nm.Name
Debug.Print Range(nm).Name
Debug.Print Range(nm).Value
Next nm
End Sub



"Steve Drenker" wrote in message
.. .
Hi. I need to retrieve values I've saved using Insert / Name / Define. In
other words, I've created a Name "Base_Year" with a stored value of 49. How
do I refer to this Name ("Base_Year") to get the associated value (49)

I can easily retrieve the values of named ranges on worksheets...
Dim rate As Double
rate = Range("Labor_rate_Admin_Base_Year").Value

How do I do the same thing when I stored a value directly in the Name?

I know I can iterate across all names as follows, but how do I get the
"n.RefersTo" of a specific "n.name"?

Dim n As Name

For Each n In ActiveWorkbook.Names
n.Name
n.RefersTo
Next n

TIA, Steve