Named Ranges in Excel: Give Your Cells Names You'll Actually Remember

 

Named Ranges in Excel: Give Your Cells Names You'll Actually Remember

A named range is a label you give to a cell or a group of cells, so you can use the name in a formula instead of a cell address. To create one, select the cells, click the Name Box (the small box to the left of the formula bar), type a name such as SalesTotal, and press Enter. After that, a formula like =SUM(SalesTotal) does the same job as =SUM(C2:C140), and is far easier to read.

I once opened a workbook I'd built about six months earlier and found a formula that read =SUM(Sheet2!$C$5:$C$140)*Sheet4!$B$2. I knew I'd written it. I had absolutely no idea what it did. It took me about twenty minutes of clicking between sheets to work out that the first part was total revenue and the second part was a tax rate sitting in a cell I'd never labelled. That was the day I started naming things. A formula that says =Revenue*GST_Rate explains itself, even to the person who wrote it half a year ago.

How do I create a named range?

There are three common ways, and the first is the quickest.

1. Using the Name Box

  1. Select the cells you want to name
  2. Click in the Name Box (left of the formula bar, where the cell address normally shows)
  3. Type the name and press Enter

2. Using Define Name

  1. Select the cells
  2. Go to Formulas > Define Name
  3. Enter the name, check the range in the Refers to box, and click OK

3. Using Create from Selection

  1. Select a block of data including its header row
  2. Go to Formulas > Create from Selection (or press Ctrl+Shift+F3)
  3. Tick Top row and click OK

The third method creates one name for each column, using the headings as names. It's useful when you have several columns to name at once.



What are the rules for naming a range?

Excel is picky about names, so these are worth knowing before you hit an error message.

  • The name must start with a letter, an underscore or a backslash
  • No spaces. Use an underscore or capital letters instead, like Sales_Total or SalesTotal
  • The name can't look like a cell address, so Q1 or A1 won't work
  • Names aren't case-sensitive, so salestotal and SalesTotal are the same name
  • Keep them short but meaningful. GST_Rate is better than Rate or TheRateForGSTCalculations

How do I use a named range in a formula?

Type the name wherever you'd normally type a cell reference. As you type, Excel offers matching names in the autocomplete list, which you can pick with the Tab key.

=SUM(SalesTotal)

You can also press F3 while editing a formula to open a list of every name in the workbook and insert one from there.

A particularly useful trick is naming a single cell that holds a fixed value, such as a rate. In Australia, GST is 10%, so you might put 10% in a cell and name it GST_Rate. Then:

=B2*(1+GST_Rate)

Anyone reading that formula can tell what it's doing. It also fixes the reference in place, which connects to what I covered in my post on "absolute vs relative references". A name always points at the same cells, so you don't need dollar signs to stop it drifting when you copy the formula down a column.

How do I see, edit or delete my named ranges?

Open the Name Manager: go to Formulas > Name Manager, or press Ctrl+F3. It lists every name in the workbook, what each one refers to, and its scope.

From there you can:

  • Edit a name to change which cells it refers to
  • Delete names you no longer need
  • Filter the list to find names with errors, which is handy when you inherit a messy workbook

Scope matters here. A name with Workbook scope works on every sheet. A name with Worksheet scope only works on the sheet it belongs to, which lets you use the same name on different sheets for different things. Most of the time, Workbook scope is what you want.



Can I use a named range in a dropdown list?

Yes, and this is where names earn their keep. Instead of pointing a dropdown's Source at a range of cells, you can point it at a name:

=RegionList

If you've read my post on "Data Validation and dropdown lists", the dependent dropdown trick there relies on named ranges, where each name matches an item in the first list. That post uses INDIRECT to connect the two lists, and it only works if the names are set up properly.

What's the difference between a named range and an Excel Table?

They overlap, but they solve slightly different problems.

Named rangeExcel Table
Expands automatically when you add rowsNo, you'd need to edit the rangeYes
Good forSingle values (like a tax rate) and fixed rangesLists of data that grow
How you refer to itSalesTotalSalesTable[Sales Amount]
SetupName Box or Define NameCtrl+T

My rule of thumb is that fixed values and settings get named ranges, and growing lists of data get Tables. If you've read my post on "Excel Tables" , you'll know a Table's columns already behave like named ranges that expand on their own, so there's no need to name those columns separately.

Why is my formula showing #NAME?

Usually one of these:

  1. The name is misspelled. Excel can't find a name that doesn't exist, so it returns #NAME?. Check the spelling against the Name Manager list.
  2. The name was deleted. Formulas that used it will show an error until you recreate the name.
  3. The name has Worksheet scope and you're on a different sheet. It only works on its own sheet.
  4. The name refers to cells that no longer exist. If someone deleted the rows or columns it pointed at, the name's Refers to box will show #REF!, which you can fix by editing it in the Name Manager.

FAQ

How do I jump to a named range quickly? Click the arrow beside the Name Box and pick the name from the list, or press F5 (or Ctrl+G), type the name, and press Enter. Excel jumps straight to those cells.

Does a named range update if I insert rows inside it? Yes. If you insert a row in the middle of the range, the name expands to include it. If you add rows below the last row, it doesn't. That's the main reason growing lists are better as Tables.

Can I name a formula or a constant, not just cells? Yes. In Define Name, type a value like =0.1 or a formula in the Refers to box, and the name stands for that. It's a neat way to keep a constant such as GST in one place.

Are named ranges a problem when I share the file? No, they travel with the workbook. Just remember that if you copy a sheet to another workbook, its names can come along too, and you may end up with duplicates. Check the Name Manager afterwards.

Is it worth naming every range in a workbook? No. I name the things I refer to often or that need explaining, like rates, key lists and main totals. Naming everything creates clutter that's as confusing as having no names at all.

Comments

Popular posts from this blog

How to Record a Macro in Excel (No Coding Needed)

Excel Charts: How to Choose the Right Chart Type

Flash Fill in Excel: How Ctrl+E Splits and Combines Text Automatically