Friday 10 July 2015

Named Ranges in Excel

Named Ranges in Excel

A Named Range is way to describe your formulas. So you don't have to have this in a cell:
= SUM(B2:B4)
You can replace the cell references between the round brackets. You replace them with a descriptive name, all of your own. So you could have this, instead:
= SUM(Monthly_Totals)
Behind the Monthly_Totals, though, Excel is hiding the cell references. We'll see how it works, now.
Open up Excel and create the spreadsheet below:
Create this Excel 2007 Spreadsheet
The formula is in cell B5, and just adds up the monthly totals in the B column.

Define a Name

Setting up a Named Range is a two-step process. You first Define the Name, and then you Apply it. To Define your name, do this (make sure you have the formula in cell B5):
  • Highlight the cells B2 to B4 (NOT B5), then click the Formulas menu
  • Locate the Named Cells panel in Excel 2007. In Excel 2010 and 2013, locate the Defined Names panel instead.
  • Click Name a Range in Excel 2007 and Define Name in Excel 2010 and 2013
The Named Cells panel in Excel 2007
From the Name a Range menu, click Name a Range (Define Name again in Excel 2010/13):
Click on Name a Range
You'll then get the following dialogue box:
The New Name dialogue box
Click OK on the New Name dialogue box. Notice that the Name is our heading ofMonthly_Totals.
When you click OK, you'll be returned to your spreadsheet. You won't see anything changed. But what you have done is to Define a Name. You can now Apply it.

Apply a Name

To apply your new Name, click into cell B5 where your formula is, and do this:
  • On the Named Cells panel, Click Name a Range. For Excel 2010/13 users click Define Name > Define Name
  • From the menu, select Apply Names
  • From the Apply Names dialogue box, select the Name you want and click OK:
The Apply Names dialogue box
When you click OK, Excel should remove all those cell references between the round brackets, and replace them with the Name you defined:
The new Name has been applied
In the image above, cell B5 now says:
=SUM(Monthly_Totals)
The cell references have been hidden. But Excel still knows about them - it's you that can't see them!

Exercise
Study the spreadsheet below, now that we have added another Named Range to cell C5:
A Named Range in cell C5
Using the same techniques just outlined, create the same Named Range as in our image above. Again, the formula we've used is just a SUM formula:
= SUM(C2:C4)
You need to start with this, before you Define the Name and Apply it.

Using Named Ranges in Formulas

We'll now use two Named Ranges to deduct the tax from our monthly totals.
So, to define two new Names, do the following:
  1. Click inside cell B5 to highlight it
  2. From the Formulas menu bar, locate the Named Cells panel, and click Name a Range > Name a Range (Excel 2007). In Excel 2010/13, click Define Name > Define Name from the Defined Names panel.
  3. From the New Name dialogue box, click in to the Name textbox at the top and enter Monthly_Result (with the underscore character)
  4. Click OK
  5. Click inside cell C5 and do the same as step 2 above. This time, however, enter Tax_Result as the Name
You should now have two new Names defined. We'll now Apply these new names. First, add a new label to your spreadsheet:
Click in to cell B7, next to your new label, and enter the following formula:
= B5 - C5
With the formula in place, we can Apply the two new Names we've just defined:
  • From the Formulas menu bar, locate the Named Cells panel, and click Name a Range > Apply Names (Excel 2007). In Excel 2010/13, click Define Name > Apply Names from the Defined Names panel.
  • The Apply Names dialogue box appears
  • Click Monthly_Result to select it
  • Click on Tax_Result to select it:
Apply both names
  • Click the OK button
  • Excel will replace your cell references with the two Names you Defined
  • Your spreadsheet should look like ours:
The final spreadsheet
If you look at the formula bar, you'll see the two Named Ranges. The formula is easier to read like this. But it's not terribly easy to set up! They can be quite useful, though.

In the next part, we'll take a look at how to set up your own custom names that you can use in formulas.

0 comments:

Post a Comment