
Tips.Net > ExcelTips Home > Formulas > Relative References within Named Ranges
Summary: Named ranges are a great boon when putting together formulas. They can make complex cell references easier and faster. This tip explains some additional ways you can refer to specific cells within a named range. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
Chris has set up a worksheet where he uses named ranges (rows) in his formulas. He has named the entire sales row as "Sales," and then uses the Sales name in various formulas. For instance, in any given column he can say =Sales, and the value of the Sales row, for that column, is returned by the formula. Chris was wondering how to use the same formula technique to refer to cells in different columns.
There are a couple of different ways this can be done. First of all, you can use the INDEX function to refer to the cells. The rigorous way to refer to the value of Sales in the same column is as follows:
=INDEX(Sales,1,COLUMN())
This works if the Sales named range really does refer to the entire row in the worksheet. If it does not (for instance, Sales may refer to cells C10:K10), then the following formula refers to the value of Sales in the same column in which the formula occurs:
=INDEX(Sales,1,COLUMN()-COLUMN(Sales)+1)
If you want to refer to a different column, then simply adjust the value that is added to the column designation in the INDEX function. For example, if you wanted to determine the difference between the sales for the current column and the sales in the previous column, then you would use the following:
=INDEX(Sales,1,COLUMN()-COLUMN(Sales)+1) - INDEX(Sales,1,COLUMN()-COLUMN(Sales))
The "shorthand" version for this formula would be as follows:
=Sales - INDEX(Sales,1,COLUMN()-COLUMN(Sales))
There are other functions you can use besides INDEX (such as OFFSET), but the technique is still the same—you must find a way to refer to an offset from the present column.
There is an easier way to get at the desired data, however. Let's say that your Sales range also has a heading row about it, similar to what is shown in the following figure. (Click here to see a related figure.)
The heading row lists the years for the range, and the values under the headings are those that actually make up the Sales range. To make sure this technique will work, follow these steps for a version of Excel prior to Excel 2007:
If you are using Excel 2007, then you should follow these steps instead:
With this configuration change done, you can use the following as your formulas:
=Sales '2006' – Sales '2001'
What you are actually doing is instructing Excel to work with unions of cells. In this instance, Sales '2006' returns the cell at the intersection of the Sales range and the '2006' column. A similar union is returned for the portion of the formula to the right of the minus sign. The result is the subtraction of the two values you wanted.
Tip #3202 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Save Time! ExcelTips has been published weekly since late 1998. Past issues of ExcelTips are available in convenient ExcelTips archives. Have your own enhanced archive of ExcelTips at your fingertips, available to use at any time!
Check out ExcelTips Archives today!
PivotTables don't need to be scary or mysterious. Use this powerful tool to analyze your data in ways you didn't know were possible. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site