Professional Documents
Culture Documents
Excel VBA Programming For Dummies PDF
Excel VBA Programming For Dummies PDF
If you use lots of named cells and ranges in your workbook, you may be surprised to discover that
Excel provides no way to list the details for each name. Useful information appears in the Name
Manager dialog box, but there is no way to display this information in a manner that can be printed.
The VBA code below generates a useful report that describes the names defined in any workbook.
The report, which is created on a new worksheet, includes the following information for each name:
Wiley, the Wiley logo, For Dummies and all related trademarks, logos, and trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates.
Creating a Name Report in Excel
®
Scope: The scope of the name, either Workbook, or the name of the specific worksheet on which
the name is valid.
Hidden: True if the name is hidden. Hidden names are created by some add-ins (such as Solver),
and do not appear in the Name Manager dialog box.
Error: True if the name contains an erroneous reference.
Link: A hyperlink that, when clicked, activates the named range. Only names that refer to cells or
ranges include a link.
Comment: The comment for the name, if any.
Dim n As Name
Dim Row As Long
Dim CellCount As Variant
Wiley, the Wiley logo, For Dummies and all related trademarks, logos, and trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates.
Creating a Name Report in Excel
®
'Column B: RefersTo
Cells(Row, 2) = "'" & n.RefersTo
'Column G: Hyperlink
If Not Application.IsNA(Cells(Row, 3)) Then
ActiveSheet.Hyperlinks.Add _
Anchor:=Cells(Row, 7), _
Address:="", _
SubAddress:=n.Name, _
TextToDisplay:=n.Name
End If
Wiley, the Wiley logo, For Dummies and all related trademarks, logos, and trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates.
Creating a Name Report in Excel
®
'Column H: Comment
Cells(Row, 8) = n.Comment
Next n
Generating a Report
Execute the GenerateNameReport procedure, and the report is generated on a new worksheet in
the active workbook. The code doesn't have to be in the workbook that contains the names for the
report.
If you find this code useful, you might want to store it in your Personal Macro Workbook,
or create an add-in.
978-1-118-49037-2
Wiley, the Wiley logo, For Dummies and all related trademarks, logos, and trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates.