View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Larry A[_3_] Larry A[_3_] is offline
external usenet poster
 
Posts: 15
Default VBA code to itemize range names and associations?

Thank you. I will give this a try. May I ask, to what extent do you trust
the Name Manager add-in? I'm generally reluctant to put outside code on my
machine, but this looks pretty legit and could prove extremely useful
Thanks again. Larry.

==========================
"keepITcool" wrote in message
ft.com...


quoted code assumes that all names refer to ranges.
it will error out when the refersto contains constants or formulas that
do not evaluate to ranges.following should work

Sub ListNames()
Dim v, n&, rng As Range
On Error Resume Next
With ActiveWorkbook.Names
ReDim v(1 To .Count, 1 To 3)
For n = 1 To .Count
With .Item(n)
v(n, 1) = .Name
v(n, 2) = .RefersToR1C1
If Not IsError(.RefersToRange) Then
v(n, 3) = .RefersToRange.Address
End If
End With
Next
End With

Set rng = Application.InputBox("Dump where?", Type:=8)
With rng.Resize(UBound(v, 1), UBound(v, 2))
.NumberFormat = "@"
.Value = v
End With

End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Roman wrote :

Hi Larry, hope this helps:

Sub BuildRangeNameList()
Dim i As Integer, s As String, n As Name
For i = 1 To ActiveWorkbook.Names.Count
Set n = ActiveWorkbook.Names(i)
s = n.Name
MsgBox "Name: " & s & vbCrLf & _
"sheet: " & n.RefersToRange.Parent.Name & vbCrLf & _
"range: " & Range(n).Address
Next i
End Sub