Sub topic 4
Mixed References: Locking Only the Row or the Column
This chapter assumes you can enter and edit a formula, select cells and ranges, and copy cells or use the fill handle. It also assumes you know relative references (A1) and absolute references ($A$1) from the previous chapters. Here you will learn the third kind, the mixed reference. A mixed reference locks one half of an address and lets the other half move.
What a mixed reference is
A cell address has two parts: a column letter and a row number. The dollar sign $ locks the part that follows it. That gives four forms of the same address:
| Form | Example | Column when copied | Row when copied |
|---|---|---|---|
| Relative | `B2` | moves | moves |
| Absolute | `$B$2` | locked | locked |
| Mixed, column locked | `$B2` | locked | moves |
| Mixed, row locked | `B$2` | moves | locked |
A mixed reference has exactly one dollar sign. The dollar sign always sits directly in front of the part it protects. In $B2 the $ is in front of B, so the column is fixed. In B$2 the $ is in front of 2, so the row is fixed.
Excel does not care which part you lock when you type the formula. It only matters when the formula is copied or filled to another cell. At that moment Excel shifts every unlocked part by the same distance and direction as the move.
Why you need them
Absolute references solve the case where one cell feeds every formula, such as a single tax rate. Relative references solve the case where each formula uses its own neighbours. Many real tables need something in between. One input varies by row, another varies by column, and each must stay in its own lane.
Typical cases:
- A multiplication table, where row headings run down the left and column headings run across the top.
- A price grid, where unit prices run down and discount rates run across.
- A loan or growth table, where rates run across the top and years run down the side.
- A commission table, where each salesperson's base is in a column and each tier rate sits in a header row.
In all of these you want one formula that you write once and fill over the whole block.
Worked example: a multiplication table
Set up the sheet like this. Put the numbers 1 to 9 in A2:A10, and the numbers 1 to 9 in B1:J1. The cell A1 stays empty.
The goal is to fill B2:J10 with the products. Consider the formula in B2:
B2: =$A2*B$1Read it piece by piece:
$A2locks the column toA. As you fill right, it keeps reading the row heading column. As you fill down, the row number moves, so each row picks up its own heading.B$1locks the row to1. As you fill down, it keeps reading the top header row. As you fill right, the column letter moves, so each column picks up its own heading.
Now fill the formula across and down. These are the results in a few cells:
| Cell | Formula after fill | Reads |
|---|---|---|
| `B2` | `=$A2*B$1` | row heading 1, column heading 1 |
| `C2` | `=$A2*C$1` | row heading 1, column heading 2 |
| `B3` | `=$A3*B$1` | row heading 2, column heading 1 |
| `D4` | `=$A4*D$1` | row heading 3, column heading 3 |
You can see the pattern: the locked part of each reference never changes, and the free part follows the cell.
What goes wrong with the other choices
It helps to see the failure cases. Suppose you wrote the formula with the wrong lock in B2 and filled it across and down.
| Formula in B2 | Result of the fill | Why |
|---|---|---|
| `=A2*B1` | Wrong values and, further out, references to empty cells | Both references drift in both directions. In `C3` it becomes `=B3*C2`, which multiplies the wrong cells. |
| `=$A$2*$B$1` | Every cell shows the same value | Nothing moves, so every cell multiplies the first heading pair. |
| `=A$2*$B1` | Wrong values | The locks are on the wrong parts. The row heading column drifts and the row it reads is stuck. |
The third row is a common slip. The lock must protect the direction in which the heading does not change. Ask yourself: along which direction does this input stay constant?
- Row headings in a column down the left stay constant as you move across a row. Lock the column:
$A2. - Column headings in a row along the top stay constant as you move down a column. Lock the row:
B$1.
A rule for choosing the lock
For each reference in your formula, ask two questions about the cell you are pointing at.
- When I fill to the right, should this reference move to the next column? If not, put
$before the column letter. - When I fill down, should this reference move to the next row? If not, put
$before the row number.
Do this reference by reference. A single formula can combine relative, absolute and mixed references. Here is a price grid example, with unit prices in A2:A6, discount rates in B1:F1, and the formula in B2:
B2: =$A2*(1-B$1)The unit price comes from column A for every column, so the column is locked. The discount comes from row 1 for every row, so the row is locked. The constant 1 is a plain number and needs no reference.
Adding a fixed input as well
You can mix all three types in one formula. Suppose each price in the grid also needs a flat shipping charge stored in H1:
B2: =$A2*(1-B$1)+$H$1Here $A2 and B$1 are mixed, and $H$1 is absolute. Filled across and down, $H$1 never changes, so every cell adds the same shipping charge.
Mixed references and the F4 key
Typing dollar signs by hand is slow and error-prone. While your cursor is on or inside a reference in the formula bar, pressing F4 cycles that reference through the four forms in a fixed order:
B2(relative)$B$2(absolute)B$2(row locked)$B2(column locked)
Press it a fifth time and it returns to B2. The order catches many people out: the row-locked form comes before the column-locked form. On some laptops you need to hold Fn as well, and on a Mac the shortcut is Cmd+T in many versions or Fn+F4. A later chapter covers this key in more detail.
Mixed references in ranges
A range has two corners, and each corner is a separate reference. You can lock each corner on its own. In $A2:C$5, the first corner $A2 has its column locked, and the second corner C$5 has its row locked.
This is what makes an expanding range possible. A later chapter treats running totals in full, but the mixed form is worth seeing here. If you only need the start fixed while the end moves down, you can write:
C2: =SUM($B$2:B2)The first corner is absolute and the second is relative. A fully mixed version looks like this when you want the start's column fixed but its row free, which is rare and usually a sign you should reconsider the design.
A percentage-of-column-total table
Another practical use is a table where each column has its own total at the bottom, and you want each cell shown as a share of its own column total. With data in B2:D10 and totals in row 11:
F2: =B2/B$11Fill this across and down. The column letter moves so each column divides by its own total. The row is locked at 11, so every row in that column divides by the same total. If you had written B2/B11 the divisor would slip down into empty cells and give #DIV/0! errors.
In the opposite layout, where each row has its total in column E, you would lock the column instead:
G2: =B2/$E2The mirrored lock follows the mirrored layout. This is a good test of understanding: whenever the layout flips, the dollar sign flips with it.
Edge cases and gotchas
Filling in only one direction
If you only fill down, a lock on the column makes no visible difference, because the column never changes anyway. The same is true for a row lock when you only fill right. Many people add a full absolute reference when a mixed reference would do. That works until the table later grows in the other direction. If you plan to extend a table both ways, use the mixed form so the formula keeps working.
Copy versus fill
Copy and paste, and fill with the handle, both apply the same shifting rule to relative parts. The shift is measured from the source cell to each destination cell. If you copy B2 and paste it into E7, the free parts shift by three columns and five rows. A column that is locked does not shift, and a row that is locked does not shift.
Hitting the edge of the sheet
If a free part would shift past the edge of the sheet, for example a reference to column A filled to the left, or row 1 filled upward, Excel returns #REF!. A mixed reference can protect you here, because the locked part never moves toward the edge.
Locks do not protect against cut and paste
Cut and paste moves a cell without changing the formula text, and it changes references that point to the moved cell. A dollar sign has no effect on that behaviour. The next chapters cover this in detail, but remember for now that the $ only controls what happens when a formula is copied or filled. It does not freeze a cell in place.
Locks do not protect against inserting rows
If you insert a row above row 1, a reference such as B$1 becomes B$2. The $ means "do not shift when copied", not "never change". Excel still updates references to follow the data they point at when the structure of the sheet changes.
Debugging a mixed reference
When a filled table gives odd values, work through this short routine.
- Click the first cell that looks wrong, not the first cell in the table. Press
F2to see the colour-coded boxes Excel draws around each referenced cell. - Compare the highlighted cells to the ones you intended. Note which reference points to the wrong place.
- Decide in which direction that reference should have stayed fixed. Lock that part.
- Fix the formula in the top-left cell, then fill it over the whole block again, rather than patching individual cells.
- Check one cell in each corner of the block by hand. The corners expose lock mistakes quickly because they have moved the farthest from the source.
You can also turn on formula display with Ctrl+` (the backtick key) to read all the formulas in the grid at once. Look down one column and across one row. In a correct mixed-reference table, one letter or one number in each reference stays the same, while the other steps by one.
Summary
- A mixed reference has one
$. It locks the column ($B2) or the row (B$2) and lets the other part follow the formula. - Use it when one input varies along the rows and another along the columns, so a single formula can fill a whole grid.
- Choose each lock by asking in which direction that input must not change.
F4cyclesB2,$B$2,B$2,$B2.- The
$controls copy and fill behaviour only. It does not stop Excel from adjusting references when you cut cells or insert and delete rows.
Exercise
Row 1 (B1:F1) holds interest rates and column A (A2:A8) holds loan amounts. Write the formula for B2 that gives the yearly interest for that loan amount at that rate, so it can be filled over B2:F8. Then state what the formula in D5 looks like after the fill.
Show answer
B2: =$A2B$1. After the fill, D5 contains =$A5D$1. The column is locked on A so every cell reads the loan amount from column A, and the row is locked on 1 so every cell reads the rate from row 1.
Exercise
A table has sales in B2:D10 and column totals in B11:D11. Someone enters =B2/B11 in F2 and fills it across and down. Why does it fail, and what is the correct formula?
Show answer
Both parts of B11 are relative, so as the formula is filled down it points to B12, B13 and so on, which are empty, and the division gives #DIV/0! errors. The totals sit in row 11 for every row, so the row must be locked: =B2/B$11. The column stays free so each column divides by its own total.
Exercise
You press F4 repeatedly while the cursor is on B2 inside a formula. List the forms you see, in order, starting from B2.
Show answer
B2, then $B$2, then B$2, then $B2, and then it returns to B2.