Chapter 5. Using Names

One of the most useful features in Excel is the ability to create names. You can create a name by selecting the Formulas tab on the Ribbon and clicking the Name Manager button to display the Name Manager dialog box, shown in Figure 5-1. If the name refers to a range, you can create it by selecting the range, typing the name into the Name box at the left side of the Formula bar, and pressing Enter. However, in Excel, names can refer to more than just ranges.

Figure 5-1

Figure 5-1. Figure 5-1

A name can contain a number, text, or a formula. Such a name has no visible location on the worksheet and can only be viewed in the Name Manager dialog box. Therefore, you can use names to store information in a workbook without having to place the data in a worksheet cell. Names can be declared hidden so they don't appear in the Name Manager dialog box. This can be a useful way to keep the stored information from being seen by users.

The normal use of names is to keep track of worksheet ranges. This is particularly useful for tables of data that vary in size. If you know that a certain name is used to define the range containing the data you want to work on, your VBA code can be much simpler than it might otherwise be. It is also relatively simple, given a few basic techniques, to change the definition of a name to allow for changes that you make to the tables in your code.

The Excel object ...

Get Excel® 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.