Named ranges are cells, ranges, tables, formulas, or constant values that are represented with meaningful names, that are tied to their workbook reference (i.e. A1, B23, A1:B23). Using named ranges make formulas easier to read and maintain. In this guide, we're going to show you 5 different ways to create an Excel named range.
Name Box
When dealing with fewer number of fields, the easiest way to create an Excel named range is using the Name Box next to the formula bar.
- Select a cell or range
- Type a proper name into the Name Box
- Press Enter
Create from Selection
Create from Selection is a very useful feature that allows adding multiple names at once. As a prerequisite, you need to type in the names in adjacent cells of the cell(s) or range(s) you want to name. This feature works best with cells in a list or table layout containing titles (to be used as names).
- Select a range that also contains the names
- Click Formulas > Create from Selection
- Select the row/header option(s) based on where the names are in your table or list
- Click OK
Please see How to name multiple cells at once using the Create from Selection feature article for more details on this feature.
Define Name
Define Name is an icon in the Ribbon that can be used to add a single named range. Unlike the Name Box method, the Define Name approach allows selecting a specific worksheet as the scope, and adding a comment.
- Select a cell or range
- Click Define Name under the Formulas tab
- Enter a name
- (Optional) Set a scope and add a comment.
- Click OK
Name Manager
Name Manager works very much like the Define Name method. Here, the New button creates new names, and you can manage existing names by selecting them and clicking Edit, or remove them by pressing Delete.
- Select a cell or range
- Click Name Manager under the Formulas tab
- Click New
- Enter a name
- (Optional) Set a scope and add a comment.
- Click OK
VBA (Macro)
You can also use a macro to create named ranges. Using a macro to generate names can be especially useful if you need to add several names in bulk or you want to add names automatically.
Below is simple code block to add a named range. You can build on it, like using an array of names and looping through it to create named ranges. Follow to steps below before going into the code:
- Press the Alt + F11 combination to open the Visual Basic for Applications (VBA) window.
- Follow Insert > Module to add an editor module where you will create your code
- Activate the new window (usually named Module1)
- Create your code (or copy & paste from below)
- (Optional) Update the myname and myrange variables
Sub AddName() Dim myname As String, myrange As String myname = "NewName" myrange = "Sheet1!B2:D5" ActiveWorkbook.Names.Add _ Name:=myname, _ RefersTo:=Range(myrange) End Sub