0% found this document useful (0 votes)
166 views

All Rights Reserved: Free Preview - Week #8 Learn Excel From MR Excel

When you copy a formula, all of the relative cell references are automatically adjusted. Relative references move in all four directions. It is possible to copy formula so that it will point to a cell that does not exist.

Uploaded by

octo pus
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views

All Rights Reserved: Free Preview - Week #8 Learn Excel From MR Excel

When you copy a formula, all of the relative cell references are automatically adjusted. Relative references move in all four directions. It is possible to copy formula so that it will point to a cell that does not exist.

Uploaded by

octo pus
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Free Preview – Week #8

Learn Excel from Mr Excel


Copyright 2005 Bill Jelen
All Rights Reserved

Encourage your friends to sign up at


http://www.mrexcel.com/learn-excel.html.

This Week: topics on relative, absolute, and


mixed references.
COPY A FORMULA THAT
CONTAINS RELATIVE REFERENCES
Problem: You have 5,000 rows of data. After entering a formula to cal-
culate Gross Profit Percent for the first row, as shown in Fig. 167, how
do you copy the formula down to other rows?
Part
II

Fig. 167

97
98 of 654 LEARN MICROSOFT EXCEL

Strategy: All of the cell references in the formula are known as rela-
tive references. The amazing thing about Excel is that when you copy a
formula, all of the relative cell references are automatically adjusted. If
you copy a formula from row 2 down to row 3, as shown in Fig. 168, then
every reference pointing at row 2 will change to point at row 3.

Fig. 168

So, the solution to the problem is simply to copy the formula down to
all the other rows. A shortcut for doing this is to select the cell and then
double-click the Fill handle to copy the formula down to all rows with
values in the adjacent column.
Additional Details: Relative references will move in all four directions.
In Fig. 169, if you copy the formula in cell F7 to E6, the referenced cell
will change from D3 to C2.

Fig. 169

In Fig. 170, you can see how the formula copied from F7 to E6:G8 will
change.
Part 2: CALCULATING with excel 99 of 354

Fig. 170
Part
II
Hint Fig. 170 was shot in Show Formula mode. To enter Show
Formula mode, hit Ctrl+~. To toggle back to regular mode,
hit Ctrl+~ again.

Gotcha: It is possible to copy a formula so that it will point to a cell that


does not exist. As shown in Fig. 171, what would happen if you copied
C4 to B3?

Fig. 171

The reference to A1 would have to point to the cell one row above and
one column to the left of A1. This cell does not exist, so Excel will return
a #REF error, as shown in Fig. 172.

Fig. 172
100 of 654 LEARN MICROSOFT EXCEL

Summary: The ‘miracle’ of Excel is that you can enter a formula in one
place and copy it to many other places and it will still work. This is be-
cause a regular cell reference, such as B1, is a relative reference.

COPY A FORMULA WHILE


KEEPING ONE REFERENCE FIXED
Problem: You have 5,000 rows of data. As shown in Fig. 173, each row
contains a quantity and the unit price. The sales tax rate for all orders
is shown in cell C1. After entering a formula to calculate the total with
sales tax in the first row, how do you copy the formula down to other
rows?

Fig. 173

If you copy the formula in F4 to F5, you get an invalid result, as shown
in Fig. 174.

Fig. 174
Part 2: CALCULATING with excel 101 of 354

Look at the formula in the formula bar in Fig. 174. As you copied the
formula, the references to D4 and E4 changed as expected. However, the
reference to C1 moved to C2. You need to find a way to copy this formula
and always have the formula reference C1.
Frankly, this is the most important technique in the entire book. I once
had a manager who would enter every formula by hand in the entire
dataset. I didn’t have the heart to tell him there was an easier way.
Strategy: You need to indicate to Excel that the reference to C1 in
the formula is Absolute. Do this by inserting a dollar sign before the
C and before the 1 in the formula. The formula in F4 would change to
=ROUND((D4*E4)*$C$1,2).
As you copy this formula down to other rows in your dataset, the por- Part
tion that refers to $C$1 will continue to point at $C$1, as shown in II
Fig. 175.

Fig. 175

Additional Details: See the next chapter to understand the effect of


using just one dollar sign in a reference instead of two. Read “Simplify
Entry of Dollar Signs in Formulas” a few chapters after that to learn a
cool shortcut for entering the dollar signs automatically.
Summary: Entering dollar signs in a reference will lock the reference
and make it absolute. No matter where you copy the formula, it will con-
tinue to point to the original cell.
Functions Discussed: =ROUND()
Cross Reference: Create a Multiplication Table; Simplify Entry of Dol-
lar Signs in Formulas
102 of 654 LEARN MICROSOFT EXCEL

CREATE A MULTIPLICATION TABLE


Problem: Create a multiplication table to help your kids in school. In
Fig. 176, you want to enter a single formula in cell B2 that can be copied
to the entire table.

Fig. 176

Strategy: In the last chapter, you learned how to use an absolute refer-
ence, such as $C$1, so that Excel would not change from column C or
row 1 as it copied the formula. To create a multiplication table, you need
to use a mixed reference. A mixed reference, such as $B1, will lock the
formula to column B, while allowing the row to change. A mixed refer-
ence, such as B$1, will lock the row to row 1, while allowing the column
to change.
The formula that you need for the multiplication table is a formula that
will multiply whatever is in row 1 above the cell by whatever is in col-
umn A to the left of the cell.
To have a reference that always points to row 1, use something in the
format of B$1. To have a reference that points to column A, use a refer-
ence in the format of $A2.
1) As shown in Fig. 177, the formula you want to enter in B2 is
=$A2*B$1.
Part 2: CALCULATING with excel 103 of 354

Fig. 177

2) Copy the formula in B2 to the entire range, and it will always prop-
erly multiply row 1 by column A as shown in Fig. 178.

Part
II

Fig. 178

Summary: Using a single dollar sign in a cell reference will create a


mixed reference. Only the row or column will be fixed as you copy the
formula.
104 of 654 LEARN MICROSOFT EXCEL

CALCULATE A SALES COMMISSION


Problem: The VP of Sales in your company dreamt up the most con-
voluted sales plan in the history of the world. Rather than just pay the
reps a straight commission, this plan involves a base rate of 2 percent,
bonuses based on the product sold, and the monthly profit sharing bo-
nuses. For the spreadsheet shown in Fig. 179, using Relative, Mixed,
and Absolute formulas, create a formula that can be copied to all rows
and all months.

Fig. 179

Strategy: This formula will contain all four reference types. While en-
tering the first formula in H6, you will want to base the commission cal-
culation on the January sales in E6. As you copy the formula from Janu-
ary to February, you will want the E6 reference to be able to change to
F6. As you copy the formula down to other rows, you will want the E6 to
change to E7, E8, etc. Thus, the E6 portion of the formula needs to be a
relative reference and will have no dollar signs.
You will multiply the sales times the base rate in B1. As you copy the
formula to other months and rows, it always needs to point to B1. Thus,
you need to use dollar signs to before the B and before the 1: $B$1.
To incorporate the product bonus, you will need to multiply sales by the
Product Rate in column C. All of the months in row 6 will have to refer
to C6. All of the months in row 7 will have to refer to C7. Thus, you need
a mixed reference where column C is locked. Use the address of $C6.
Finally, the VP of Sales added the monthly profit sharing bonus. The
entire commission calculation is multiplied by the bonus factor shown
in row 1. The January commission calculation uses the factor in E1. The
February factor is in F1. The March factor is in G1. In this case, you
Part 2: CALCULATING with excel 105 of 354

need to allow the formula to point to different columns but always to row
1. This requires a mixed reference of E$1.
Now that you have the four components of the formula, you can enter
this formula in E6, as shown in Fig. 180: =E6*($B$1+$C6)*E#1.

Fig. 180
Part
Result: As shown in Fig. 181, you have created one single formula that II
can be copied to all columns and rows of your dataset.

Fig. 181

Summary: The concept of relative, absolute, and mixed references is


one of the most important concepts in Excel. Being able to use the right
reference will allow you to create a single formula that can be copied
everywhere.
106 of 654 LEARN MICROSOFT EXCEL

SIMPLIFY ENTRY OF
DOLLAR SIGNS IN FORMULAS
Problem: It is a pain to type the dollar signs in complex formulas such
as the formula shown in Fig. 182.

Fig. 182

Strategy: Use the F4 key as you are entering the formula. The F4 key
will toggle a reference through the four possible reference types.
As shown in Fig. 183, start to type the formula =E7*(B1.

Fig. 183

Immediately after you type B1, hit the F4 key. Excel will insert both dol-
lar signs in the B1 reference, as shown in Fig. 184.

Fig. 184

As an illustration, hit the F4 key again. Excel changes from an absolute


reference to a mixed reference, with the row portion of the reference
locked, as shown in Fig. 185.

Fig. 185
Part 2: CALCULATING with excel 107 of 354

Hit the F4 key again. Excel changes to a mixed reference, with the col-
umn portion of the reference locked, as shown in Fig. 186.

Fig. 186

Hit the F4 key once more. Excel changes back to a relative reference, as
shown in Fig. 187.

Part
II

Fig. 187

Here are the steps for entering the complex formula shown in Fig. 182.
1) Type =E7*(B1.
2) Hit the F4 key once.
3) Type +C7.
4) Hit the F4 key 3 times. Your formula will now appear as shown in
Fig. 188.

Fig. 188

5) Type the parentheses, an asterisk for multiplication, and E1, as


shown in Fig. 189.

Fig. 189
108 of 654 LEARN MICROSOFT EXCEL

6) Hit the F4 key twice to change E1 to a reference with the row locked,
as shown in Fig. 190.

Fig. 190

7) Hit Ctrl+Enter to accept the formula without moving the cell point-
er to the next cell, as shown in Fig. 191.

Fig. 191

8) With the mouse, grab the Fill handle (the square dot in the lower
right corner of the cell) and drag it to the right for two cells, as
shown in Fig. 192.

Fig. 192

This will copy the formula from January to the other two months, as
shown in Fig. 193.

Fig. 193

9) Double-click the Fill handle. This will copy the three cells down to
all of the rows with data, as shown in Fig. 194.

Fig. 194

Fig. 194
Part 2: CALCULATING with excel 109 of 354

Additional Information: You might find mixed references confusing.


As you work on building the first formula, you might know that you
need to point to C7. Enter C7 in the formula and then use F4 to toggle
between the various reference types. Say to yourself, “OK. There is a
dollar sign before the C that will lock the column and let the row change
– is that what I need?”. As long as you say this to yourself without your
lips moving, your officemates won’t think any less of you.
Further Information: If you did not add the dollar signs as you typed
the formula, you can still use the F4 trick later.
Using the mouse, highlight the proper reference in the formula bar, as
shown in Fig. 195.
Part
II

Fig. 195

After the reference is highlighted, you can hit the F4 key to toggle that
particular reference through the four states, as shown in Fig. 196.

Fig. 196

Summary: Master the F4 key to easily add dollar signs to a reference in


order to toggle it from relative to absolute to mixed to mixed.
110 of 654 LEARN MICROSOFT EXCEL

LEARN R1C1 REFERENCING TO


UNDERSTAND FORMULA COPYING
Problem: All of a sudden, the column letters along the top of your
spreadsheet have been replaced by numbers, as shown in Fig. 197. None
of the formulas that you enter will work.

Fig. 197

Strategy: Relax. There are two ways of naming cells. Someone has
turned on the R1C1 style of addressing. To return to the normal A1 style
of cell addressing, go to Tools – Options. On the General tab, uncheck
the box for R1C1 Reference Style, as shown in Fig. 198.

Fig. 198

But wait – while you are here, you can learn something fascinating about
spreadsheets. In the topic “Copy a Formula That Contains Relative Ref-
erences”, I suggested it was miraculous that Excel could automatically
change a formula as you copied it. If you take two minutes to learn about
this other method of cell addressing, you will understand that it may not
be so amazing after all.
Part 2: CALCULATING with excel 111 of 354

When Dan Bricklin and Bob Frankston invented VisiCalc, they used the
A1 style of cell naming. When Mitch Kapor started selling Lotus 1-2-3,
he used the same style. When Microsoft came out with their first spread-
sheet product – Microsoft Multiplan – they used a very different method
of cell addressing. This method is known as R1C1. In the Microsoft sys-
tem, the rows are numbered just as in the A1 system. However, the
columns are also numbered. Each cell is given a name, such as “R4C8”.
This name stands for the cell at Row 4, Column 8. This is the cell that
you and I know as H4.
In the R1C1 style, the formulas are interesting. Look at this formula in
cell D6, as shown in Fig. 199.

Part
II

Fig. 199

The formula in the formula bar says =D5+C6–B6. But when you think
about this formula in plain language, what it is really means is “Take
the cell just above me, add the interest in the cell just to the left of me,
and subtract the payment in the cell two cells to the left of me”.
Formulas in R1C1 style are more like the plain language description
above. If you want to enter a formula in D6 that points to the cell just
above, it would be =R[–1]C. The number in square brackets after the R
indicates to how many rows ahead or back you are referring. In our case,
row 5 is one row above row 6, so you would put a –1 in the square brack-
ets. There is no number after the C portion of the address, which means
that you are referring to the same column as the cell that contains the
formula.
If you want to refer to a cell that is two cells to the left of the cell with
the formula, you would use =RC[–2].
112 of 654 LEARN MICROSOFT EXCEL

As shown in Fig. 200, the formula from Fig. 199 can be restated in R1C1
style as follows:
=R[–1]C+RC[–1]–RC[–2]

Fig. 200

So, all relative references in R1C1 style have a number in square brack-
ets, either after the R or after the C or both.
It is very interesting to see how this style does absolute addresses. As
shown in Fig. 201, the formula in B6 is an absolute formula that always
points to cell E2. The formula in A1 style is =$E$2.

Fig. 201

To enter a similar absolute reference in R1C1 style, you do not include


square brackets in the address. As shown in Fig. 202, a formula of =R2C5
will ALWAYS point to cell E2.
Part 2: CALCULATING with excel 113 of 354

Fig. 202

Part
It is also possible to have mixed references. Flip back to Fig. 177 in the II
multiplication table topic. Fig. 203 shows that formula in R1C1 style:

Fig. 203

Additional Details: Now that you understand the basics of R1C1 style
formulas, you can appreciate the amazing part. Remember that Micro-
soft invented this method for their Multiplan product. Lotus 1-2-3 was
the dominant spreadsheet in the late 1980s and early 1990s. Microsoft
was battling for market share. Everyone using spreadsheets was famil-
iar with the A1 style. No one would want to learn the R1C1 style in
order to switch to Microsoft. So, in their Microsoft Excel product, they
developed an elaborate system to actually store the formulas in R1C1
style, but then to translate the R1C1 formulas to A1 style to make it
easier for all the Lotus fans to understand.
By default, Microsoft starts with the A1 style addressing. However, you
can remember from Fig. 198 that you are just one checkmark away from
switching back to R1C1 style addressing.
114 of 654 LEARN MICROSOFT EXCEL

Finally, here is the amazing part. Examine the amortization table ex-
ample in Formula View mode. (Hit Ctrl+~ to toggle into Formula View
mode.) The Formula View mode in A1 style can be seen in Fig. 204. Ev-
ery formula in column D is different.

Fig. 204

The Formula View Mode in R1C1 style can be seen in Fig. 205.

Fig. 205
Part 2: CALCULATING with excel 115 of 354

In A1 style, it seems AMAZING that Excel can change a reference from


D10 to D11 when the formula is copied down. However, look closely at
the formulas in each row of rows 7 and higher in the R1C1 style shown
in Fig. 205. Each formula in a column is identical to the formula located
just above it!
While VisiCalc and Lotus 1-2-3 made the formula replication seem
amazing because of their A1 reference style, if the Multiplan invention
of R1C1 style had taken hold, it would not seem amazing at all because,
in fact, every formula is exactly identical as you copy it down through
the rows.
If you ever plan on writing VBA macros in Excel, it is important to un-
derstand the R1C1 style of formulas. For general use in Excel, you never Part
really need to totally understand the R1C1 style, but it is interesting to II
see how Microsoft’s R1C1 style is actually superior to A1 when copying
formulas in a spreadsheet.
Summary: Learn R1C1 style formulas to better understand how formu-
las are replicated across a worksheet.
Commands Discussed: Tools – Options – General

You might also like