How do I lock certain cells in a formula in Google Sheets?

You know, I’m pretty confident in my use of Google Sheets. I use a lot of its advanced features and formulas in my daily work.

But one thing was bugging me. Every time I created a formula and then grabbed and dragged (or double-clicked) that little box in the bottom right of the cell to have it repeat, the cells would change.

The little square down the bottom of the cell

This normally is great, because it moves by a cell each time and makes my life easier.

What if I want to keep a certain cell constant in a formula?

Enter the Absolute Reference.

The absolute reference allows you to lock either or both aspects of the cell. That is it can lock the column and/or the row. This is done by simply adding a “$” before the column or row. Here is how we do it:

  • $A$1 – locks both Column and Row
  • $A1 – locks only the Column
  • A$1 – locks only the Row

Awesome!!! Now you can drag that little square wherever you want and whatever part of that cell you locked won’t change while everything else will.

F4 – The Shortcut From the Gods

So, this is all well and good, but it still means that after I have finished entering the whole formula, I have to go back into the cell and change the cell value with that dollar sign “$”.

F4 to the rescue. You can change the value live here by cycling through $A$1, $A1 and A$1 before continuing with your formula. While completing a formula simply,

  1. Click a cell or range you want to get a value from and you want to lock or make an Absolute Reference.
  2. Press <F4> until you get the desired Absolute Reference combination.
  3. Continue with the rest of your formula.
Hire a Google Workspace Developer for your Business Needs

Example – My Fruit Binge

I really love fruit (Okay, I’m ambivalent about fruit, but I am trying to sell the example here!)

I have a list of fruit that I have eaten in the last hour. My wife has caught me with a pile of cores and skins scattered around me and wants me to count how much this food binge cost me in order to make me feel bad.

Of course, I immediately run to my laptop and bring up my list of fruit I just ate. I can also remember how much each item costs (Yep, the example is breaking here, stay with me).

To work out the total costs of what I ate, I will count how many of each item and multiply that by the costs of each item.

Here is my Google Sheet so far:

Fruit Google Sheets


Let’s plug in the formula to count the total number of Bananas.

Google Sheets Countif


Things look good so far. In cell G3 I have run COUNTIF and selected the range C2:C13. And I only want it to count if the cell contains the text “Banana” which I indicate by cell E3. Finally, in cell H3 I multiply the total number of times Banana appears (G3) by the cost of the item (F3).

The end results:

Google Sheets Fruit absolute reference error

More examples of COUNTIF

Just for a lark, let’s see how that COUNTIF formula will work if I drag it down with that cheeky little box in the bottom right of the cell.

Fruit google sheets no absolute reference.

As you can see things have gone a bit Pear-shaped (nailed it!) here. We can see 2 pairs in the list in column C but the formula is only counting one in cell G7. 

Create and Publish Google Workspace Add-ons with Apps Script Course 300px

Let’s take a look at the formula in G7.

countif reading wrong cells

We can see here that the range has changed from C2:C13 to C6:C17. That is not helpful at all. We need to make these into an Absolute Reference. The fruit criterion also moved, but we wanted it to come down to read Pear so that is pear-fict (Not so good that time).

?You can support me for free by using this Amazon affiliate link in your next tech purchase :Computers & Stuff! ?

Let’s fix this up. We need to change the COUNTIF range in cell G3 to an Absolute Reference from C2:C13 to $C$2:$C$13. This is kinda awkward so let’s try that <F4> shortcut out and put in the formula again fresh. To do this I did the following steps.

  1. entered:  =COUNTIF(
  2. selected the range C2:c13
  3. hit the magical <F4> button once and it created: $C$2:$C$13
  4. entered a comma:   ,
  5. selected the range E3
  6. closed the bracket: )
  7. hit <enter>Google Sheets Absolute reference with F4

Looks good. We’ll grab that little box down the bottom again and drag (or double click) it down and see if we get that extra pear.

Absolute reference in use

Boom! It worked. We now see 2 pears counted. Check out that bottom cell. It’s locked in the range value and only changes the fruit criterion.

Absolute reference view of final cell

Just to be pear-dantic (Hey! That was okay!) let’s see how guilty we should be for our fruit binge.

Fruit binge total google sheets

$38.10? Worth it!

Did you enjoy the tutorial? Want to upskill and get a solid step-by-step course to become a pro at Google Sheets? Check out my course, Google Sheets: Learn the Essentials with Three Detailed Projects. Sign up today.

Google Sheets Shortcuts Mousepad
Google Sheets Shortcuts Mousepad
Want a fast track to boost your Spreadsheet efficiency? Grab one of these handy Google Sheets Shortcuts mousepads that I created from my store.
Google Sheets Shortcuts Mousepad Gel
Google Sheets Shortcuts Mousepad Ge


16 thoughts on “How do I lock certain cells in a formula in Google Sheets?”

  1. Hi, thanks for the infos. Do you know how to grab and drag with the mouse a single cell inside a formula?
    When you want to move a single value inside a formula but you don’t want to type the new coordinates with the keyboard.

    1. If I understand you correctly, whenever a field requires a range you can simply click and drag that range in.

  2. Hey bro, this helps me a lot. Thanks for the useful information. Cheers! ?

    1. You’re welcome, Jo. Glad you found it useful.

  3. This was exactly what I needed, and I enjoyed your humor. Thanks!

    1. I’m glad you found it helpful and a little fun. ?


  4. Slightly different problem. Lets say D1 has “=B1” but I then want to move the value of B1 to A1 and type a new value into B1. My problem is that D1 will now say “=A1” I get why that’s needed and handy, I just want a way to turn that off and to lock the formula of D1 to “=B1”

    1. Hi YogaJavaJoe,

      You might have better luck using the INDIRECT function here. In your example give this a go: =INDIRECT("B1",TRUE)


  5. Hey! Having an issue with this. I’m trying to track inputs from the most recent week, 2 weeks, month, etc. So I want values fixed to a specific range of cells. For a week, it’s sum=(A2:A8)/7. For two weeks, it’s sum=(A2:A15)/14.

    But whenever I add the new row for a new day, the formulas adjust. So it becomes sum=A3:A9)/7. etc.

    I tried the Absolute Reference, but when I added the new row it still adjusted the values from A2:A8 to A3:A9.

    Any advice?

    1. Hi cjhlambert,

      Hmm… that shouldn’t occur. What does your absolute reference look like? This: sum=($A$2:$A$8)/7

      Feel free to share an example.


  6. Thanks for the tip. The F4 formula was what I had been looking for! Awesome blog.

Leave a Reply