Sub topic 6
Using a threshold cell with absolute references
This chapter assumes you can write a basic IF formula, use comparison operators such as >=, and copy a formula down a column with the fill handle. It shows how to move a fixed value out of the formula and into its own cell, and how to keep that cell reference from shifting when you copy the formula.
Why use a threshold cell
Suppose you grade scores with this formula:
=IF(B2>=60,"Pass","Fail")The number 60 is typed into the formula. If the pass mark changes to 65, you must edit every formula that uses it. Miss one and your results become inconsistent.
A better design stores the threshold in one cell, for example F1, and has every formula read that cell. Change F1 once and every result updates.
Relative references move when copied
A reference such as B2 is a relative reference. When you copy the formula down one row, Excel adjusts the reference to B3. This is what you want for the score column, because each row has its own score.
It is not what you want for the threshold. Suppose F1 holds the target and you write this in C2:
=IF(B2>=F1,"Target met","Below target")Copy it down to C3 and Excel changes it to =IF(B3>=F2,...). Cell F2 is probably empty, and Excel treats an empty cell as 0. Almost every score then passes the test, with no error message to warn you.
Fixing the reference with dollar signs
An absolute reference uses $ signs to tell Excel not to adjust a row, a column, or both:
| Reference | Column when copied | Row when copied |
|---|---|---|
| `F1` | can change | can change |
| `$F1` | fixed | can change |
| `F$1` | can change | fixed |
| `$F$1` | fixed | fixed |
For a single threshold cell, use $F$1:
=IF(B2>=$F$1,"Target met","Below target")Copy this down and the B2 part becomes B3, B4, and so on, while $F$1 stays the same.
You do not have to type the dollar signs. Click inside the reference in the formula bar and press F4. Each press cycles through $F$1, F$1, $F1, and back to F1.
Worked example
Set up a small sheet:
- A1:
Salesperson, B1:Sales, C1:Result - E1:
Target, F1:1000 - A2:A5 hold names, and B2:B5 hold sales figures such as 1200, 850, 1000, and 640.
Enter this in C2 and copy it down to C5:
=IF(B2>=$F$1,"Target met","Below target")The results are "Target met", "Below target", "Target met", and "Below target". The value 1000 meets the target because the operator is >=, which includes equality.
Now change F1 to 900. The first and third rows still meet the target, and the second row (850) still does not. Change F1 to 800 and the second row flips to "Target met". You edited one cell, and every formula recalculated.
Thresholds in calculations
The same idea works when the result is a calculation. If the bonus rate is also stored in a cell, say F2, you can reference both:
=IF(B2>=$F$1,B2*$F$2,0)Each input that should not change when copied has its own absolute reference. Label the cells next to them (such as "Target" in E1) so anyone reading the sheet knows what they mean.
Common problems
- Results look wrong only after copying. Check whether the threshold reference lost its
$signs. Click a cell lower in the column and look at the formula bar. If you seeF5where you expected$F$1, the reference was relative. - Everything shows the same result. The threshold cell may be empty or hold text. Text such as
"1000"typed as a label does not behave like the number 1000 in a comparison. - You moved the threshold cell. Excel updates references if you cut and paste the cell, but not if you type a new reference by hand. Check formulas after rearranging the sheet.
Exercise
A worksheet has scores in B2:B20 and the pass mark in cell E1. You write =IF(B2>=E1,"Pass","Fail") in C2 and copy it down. Row 2 is correct, but later rows give wrong answers. What is the cause, and what is the corrected formula?
Show answer
E1 is a relative reference, so it becomes E2, E3, and so on in the copied formulas, and those cells are empty (treated as 0). Make it absolute: =IF(B2>=$E$1,"Pass","Fail"), then copy it down again.
Exercise
Cell F1 holds a sales target of 1000 and F2 holds a bonus rate of 0.1. Write a formula for C2 that returns the bonus (B2 times the rate) when B2 reaches the target, and 0 otherwise, so it can be copied down.
Show answer
=IF(B2>=$F$1,B2*$F$2,0)