Named Ranges - Print List?

  • Thread starter Thread starter Ian Bull
  • Start date Start date
I

Ian Bull

I have a worksheet with a large number of named ranges.

Is there any way I can print a list of these together with their references.

Thank you & Regards
Ian Bull
 
Ian,

Insert a new worksheet.

Copy, paste and Run this macro (with the new worksheet active).

Sub ListNamedRanges()
Dim NamedRange As Name
Dim x As Integer
x = 1
For Each NamedRange In Names
Cells(x, 1) = NamedRange.Name
Cells(x, 2) = NamedRange
x = x + 1
Next NamedRange
End Sub

John
 
You've already had the answer in the other posts, but one thing you might find useful is that if
you drop your zoom factor down to 39% or below, you will see the ranges highlighted on the screen.
Can help give an overall picture. Doesn't really do much for you if the ranges are single cells
though, kind hard to see.
 
Many thanks to everyone.

All very helpful.

Regards
Ian Bull

You've already had the answer in the other posts, but one thing you might
find useful is that if
you drop your zoom factor down to 39% or below, you will see the ranges
highlighted on the screen.
Can help give an overall picture. Doesn't really do much for you if the
ranges are single cells
though, kind hard to see.
 
Max,

Your first suggestion was dead simple - thank you.

A question which springs from this is - can I take a list of named ranges,
such as that we have just created, and add it to and existing table of named
ranges in another spreadsheet?

Thank you & Regards
Ian Bull

One way:
Insert a new sheet
Click on A1
Click Insert>Name>Paste>Paste List

Another way which I found very useful:

Run J.E. McGimpsey's Sub ListNamesInWorkbook()

Link: http://mcgimpsey.com/excel/listnames.html

Option Explicit

Public Sub ListNamesInWorkbook()
' by J.E. McGimpsey
' Thanks to Tom Ogilvy for help with overflow.
Const SHEETNAME As String = "Names in *"
Const ROWLIM As Long = 65500
Dim nameSht As Worksheet
Dim destRng As Range
Dim cell As Range
Dim wkSht As Worksheet
Dim shCnt As Long
Dim i As Long
Dim oldScreenUpdating As Boolean

With Application
oldScreenUpdating = .ScreenUpdating
.ScreenUpdating = False
End With
shCnt = 0
ListNamesAddSheet nameSht, shCnt
' list Workbook-level names
Set destRng = nameSht.Range("A5")
With destRng.Offset(-1, 0)
.Value = "Workbook-Level names"
.Font.Bold = True
End With
With ActiveWorkbook.Names
If .Count Then
destRng.Offset(0, 1).ListNames 'only workbook level
Set destRng = destRng.Offset(0, 1).End(xlDown).Offset(1, -1)
Else
destRng.Offset(0, 1).Value = "None"
Set destRng = destRng.Offset(0, 1)
End If
End With
With destRng.Resize(1, 3).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
Set destRng = destRng.Offset(1, 0)
For Each wkSht In ActiveWorkbook.Worksheets
With destRng
.Value = "Names in sheet """ & wkSht.Name & """"
.Font.Bold = True
Set destRng = .Offset(1, 0)
End With
With wkSht.Names
If .Count Then
For i = 1 To .Count
With .Item(i)
destRng.Offset(0, 1) = Mid(.Name, InStr(.Name,
"!") + 1)
destRng.Offset(0, 2) = "'" & .RefersTo
Set destRng = destRng.Offset(1, 0)
If destRng.Row > ROWLIM Then
ListNamesAddSheet nameSht, shCnt
Set destRng = nameSht.Range("A5")
destRng.Offset(-1, 0).Value = _
"Names in sheet """ & wkSht.Name & """"
End If
End With
Next i
Else
destRng.Offset(0, 1).Value = "None"
Set destRng = destRng.Offset(1, 0)
End If
End With
With destRng.Resize(1, 4).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
Set destRng = destRng.Offset(1, 0)
Next wkSht
With Application
.StatusBar = False
.ScreenUpdating = oldScreenUpdating
End With
End Sub

Private Sub ListNamesAddSheet( _
nameSht As Worksheet, shtCnt As Long)
Const SHEETNAME As String = "Names in "
Const SHEETTITLE As String = "Names in $ as of "
Const DATEFORMAT As String = "dd MMM yyyy hh:mm"
Dim shtName As String

With ActiveWorkbook
' Delete existing sheet and create new one
shtName = Left(SHEETNAME & .Name, 28)
shtCnt = shtCnt + 1
If shtCnt > 1 Then _
shtName = shtName & "_" & Format(shtCnt, "00")
On Error Resume Next
Application.DisplayAlerts = False
.Worksheets(shtName).Delete
Application.DisplayAlerts = True
On Error GoTo 0
Set nameSht = .Worksheets.Add( _
after:=Sheets(Sheets.Count))
End With

With nameSht
' Format headers
.Name = shtName
.Columns(1).ColumnWidth = 30
.Columns(2).ColumnWidth = 20
.Columns(3).ColumnWidth = 90
With .Range("B:C")
.Font.Size = 9
.HorizontalAlignment = xlLeft
.EntireColumn.WrapText = True
End With
With .Range("A1")
.Value = Application.Substitute(SHEETTITLE, "$", _
ActiveWorkbook.Name) & Format(Now, DATEFORMAT)
With .Font
.Bold = True
.ColorIndex = 5
.Size = 14
End With
End With
With .Range("A3").Resize(1, 3)
.Value = Array("Sheet", "Name", "Refers To")
With .Font
.ColorIndex = 13
.Bold = True
.Size = 12
End With
.HorizontalAlignment = xlCenter
With .Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 5
End With
End With
End With
End Sub
-------------------------------
 
Hi,

Use the Name Manager I pointed you to, use it to create a
list on both workbooks (List button). Then copy the names
from the listing of the "source" workbook to the target
workbook, select the names you copied in the target
workbook and start the name manager. Now click "Pickup".

Regards,

Jan Karel Pieterse
Excel TA/MVP
 
Back
Top