Locking Cells in Excel Formulas: Absolute vs Relative
In this article
To lock a cell in an Excel formula, add a dollar sign ($) before the column letter and the row number of the cell reference (e.g., change A1 to $A$1). This creates an absolute reference, which prevents the cell address from changing when you copy or drag the formula to other cells. By default, Excel uses relative references, meaning if you drag a formula down one row, the cell references also shift down one row; locking the cell ensures the formula always points to one specific location regardless of where it is moved.
What You'll Need
- A computer with Microsoft Excel installed (works across Windows, macOS, and Web versions).
- An existing spreadsheet with data to calculate.
- Basic familiarity with entering a formula starting with the equals (=) sign.
Step-by-Step
- Select the cell where you want to enter your formula. Click the cell once to make it active.
- Start your formula by typing the equals sign (=). For example, if you are calculating sales tax, you might type
=B2*. - Click the cell you want to lock. Instead of typing the address, click on the cell that contains the constant value (such as a tax rate or a discount percentage). For instance, click cell D1. Your formula will now look like
=B2*D1. - Apply the lock. While your cursor is still blinking next to or inside the cell reference (D1), press the F4 key on your keyboard. This is the fastest way to toggle through the different types of locks.
- Verify the dollar signs. After pressing F4, you should see the reference change to
$D$1. The formula now reads=B2*$D$1. - Complete the formula by pressing the Enter key.
- Test the lock. Hover your mouse over the bottom-right corner of the cell until the cursor turns into a small black cross (the Fill Handle). Click and drag the Fill Handle down to the cells below.
- Audit the results. Click on one of the new cells you just filled. Notice that while the first part of the formula (B2) changed to B3, B4, etc., the locked part ($D$1) remained exactly the same.
Common Mistakes
One of the most frequent errors is forgetting to lock the cell before dragging the formula. If you drag a relative reference first and realize the numbers are wrong, you cannot simply add the dollar signs to the first cell and expect the others to update automatically. You must correct the first formula and then drag it down again to overwrite the incorrect cells.
Another common mistake is over-locking. Users sometimes lock every single cell in a formula, which defeats the purpose of using a spreadsheet for bulk calculations. If you lock the input cell (e.g., $B$2) as well as the constant cell (e.g., $D$1), every single row in your table will show the exact same result because the formula is not allowed to move to the next piece of data.
Some users also struggle with the F4 key on laptops. Many modern laptops require you to hold the Fn key while pressing F4 to activate the function. If pressing F4 does nothing or changes your brightness/volume, try Fn + F4.
Tips
Understand the Three Types of Locking: Pressing F4 multiple times cycles through different locking modes. This is essential for creating complex tables like multiplication grids.
- Absolute Reference ($A$1): Both column and row are locked. No matter where you move the formula, it always points to A1.
- Mixed Reference - Row Locked (A$1): The column can change if you drag the formula horizontally, but the row stays at 1 if you drag it vertically.
- Mixed Reference - Column Locked ($A1): The row can change if you drag vertically, but the column stays at A if you drag horizontally.
Named Ranges: If you find dollar signs confusing, you can use a Named Range. Right-click the cell you want to lock (e.g., D1) and select "Define Name." Name it "TaxRate." Now, you can write your formula as =B2*TaxRate. Named ranges are absolute by default, meaning they are automatically locked without needing dollar signs.
Visual Checking: Always double-click a few cells in your calculated range to visually inspect the formula. If you see the reference drifting into empty cells, you know you missed a lock.
Troubleshooting
The formula is returning #VALUE! or 0: This usually happens if the locked cell contains text instead of a number, or if the relative part of the formula has shifted into an empty cell. Check that your locked reference ($D$1) is actually pointing to the cell containing your numerical value.
F4 is not working: As mentioned, check your Fn key. If that fails, you can always type the dollar signs manually. Simply click into the formula bar at the top of the screen and type the $ symbol before the letter and the number.
The results are the same for every row: You likely locked the input cell. Check your formula; if it looks like =$B$2*$D$1, the $B$2 is preventing the formula from moving to the next row of data. Remove the dollar signs from the input cell so it reads =B2*$D$1.
The formula is not updating when I change the locked cell: Ensure that your Workbook Calculation is set to Automatic. Go to the Formulas tab > Calculation Options > Automatic. If it is set to Manual, the locked cell value won't update the results until you press F9.
Frequently Asked Questions
Can I lock a whole range of cells?
Yes. If you are using a function like SUM or VLOOKUP, you can lock the entire range by highlighting the range in the formula bar and pressing F4. For example, =SUM(A1:A10) becomes =SUM($A$1:$A$10).
Does locking a cell protect it from being edited?
No. Locking a cell in a formula only affects how the formula behaves when copied. To prevent someone from changing the actual value in the cell, you must use the "Protect Sheet" feature found under the Review tab.
What is the difference between $A1 and A$1?
$A1 locks the column, meaning if you copy the formula to the right, it will always look at column A. A$1 locks the row, meaning if you copy the formula down, it will always look at row 1.
Do dollar signs work in Google Sheets?
Yes, Google Sheets uses the exact same syntax as Excel. You can use the $ symbol manually or press F4 to toggle the reference types.
Can I lock a cell across different worksheets?
Yes. When referencing another sheet, the formula looks like =Sheet2!$A$1. The dollar signs work exactly the same way to keep that external reference from shifting.