To stop an Excel formula missing the rows you add, give it a trim reference such as =SUM(B2:.B5000) or =SUM(B:.B), which works in Excel for Microsoft 365. The dot after the colon cuts off the empty rows below your last filled cell, so every new row counts. It fails in two places: a total sitting under the data in the same column, and a file opened in Excel 2021 or 2024. Use a Table with a total row there.
Last updated 16 September 2026 · by Inam Ul Haq, data analyst and automation engineer · about the author
Say you keep a sheet where someone adds a row every day, like a sales log or a list of site costs, and the total was written as =SUM(B2:B7) back when the sheet had six rows. Someone types a seventh amount in row 8, and the total does not move. Nothing turns red and no error appears, so the number just stays a little smaller than the truth.
Excel for Microsoft 365 now has a direct answer for this. You write the range with a dot next to the colon, like B2:.B5000, and Excel reads it as a trim reference. It points at a generous block of rows and then cuts off the empty ones at the bottom, so the range ends at your last filled row today and moves down on its own when a new row arrives. The function doing the work underneath is called TRIMRANGE.
I tested this in Excel on my own PC before writing any of it, and it works, but not in every layout. The biggest surprise was the older fix that still gets copied from forum answers, a dynamic range built with OFFSET and COUNTA. With one blank cell in the middle of the column it dropped the last row, so a column that should have added up to 400 showed 340, which is the exact problem it was supposed to solve.
If your total is not directly under the numbers, write the range with a dot, like B2:.B5000. If your total sits right under the numbers, use a Table with a total row instead.
A trim reference can only make a range shorter. It never reaches past the end you wrote.
Why does an Excel formula miss the rows you add?
A range like B2:B7 is a fixed address. If you insert a row inside it, Excel stretches the address for you, but a row typed underneath sits outside the address, so the formula never looks at it. I called this the SUM that stops one row short in my piece on silent spreadsheet errors, because it looks perfectly calm while it is wrong.
People have worked around it for years with the whole column, a dynamic range built with OFFSET and COUNTA, or a Table. Each works in some sheets and fails in others, and the dynamic range is the one that fails without telling you.
What goes wrong with the OFFSET and COUNTA dynamic range?
COUNTA counts how many cells in a column are not empty. The dynamic range uses that count as the height of the range, on the idea that six filled cells means the data is six rows tall. That is only true when the column has no gaps, because every blank cell inside the data makes the count one smaller, and the range loses a row from the bottom, which is exactly where your newest row lives.
Here is what I got in Excel. I put six amounts in B2 to B7, which were 120, 80, 200, 50, 90 and 60, and then cleared the third one, so the true total is 400.
| Formula | What it returned | Right? |
|---|---|---|
=SUM(OFFSET(B2,0,0,COUNTA(B:B)-1)) | 340 | No, the last row, 60, was dropped |
=SUM(B2:INDEX(B:B,COUNTA(B:B))) | 340 | No, same count and same missing row |
=SUM(B2:.B1000) | 400 | Yes |
The trim reference got it right because it does not count anything. It looks for the last filled cell and keeps every row above it, blank or not.
What do TRIMRANGE and the dot in B2:.B1000 actually do?
Microsoft describes TRIMRANGE as a function that excludes empty rows and columns from the outer edges of a range. In normal words, it walks in from the edges until it meets a cell with something in it, and it drops the empty rows it walked past. The syntax is =TRIMRANGE(range, trim_rows, trim_columns), where 1 trims the start, 2 trims the end, and 3, the default, trims both.
Most of the time you will not type the function at all, because a trim reference is the short way to write it. Where you put the dot tells Excel which side to trim, and Microsoft's page gives these equivalents.
| You write | Same as | What gets trimmed |
|---|---|---|
A1:.E10 | TRIMRANGE(A1:E10,2,2) | Empty rows and columns at the end |
A1.:E10 | TRIMRANGE(A1:E10,1,1) | Empty rows and columns at the start |
A1.:.E10 | TRIMRANGE(A1:E10,3,3) | Both ends |
B:.B | TRIMRANGE(B:B,2,2) | Everything below the last filled cell in column B |
Two things I checked in Excel matter more than the syntax. First, blank cells in the middle stay in, so the range never loses a row the way the COUNTA version did. Second, a trim can only make a range shorter. When I typed 999 into B1500, =SUM(B2:.B1000) ignored it because row 1500 is past the end I wrote, so write the end well past where your data will ever reach, or use B:.B.
Where does a trim reference beat a whole column or a big fixed range?
If all you need is a plain SUM, the honest answer is that =SUM(B:B) already picks up new rows, and SUM skips empty cells and text anyway. The trim reference does no harm there, but it is not what fixes anything. It starts to matter when a formula works row by row, because then every empty row in the range turns into a real zero.
I tested that with a price column next to the amounts and asked for the average of amount times price. =AVERAGE(B2:B1000*C2:C1000) returned 1.2, because 993 of its 999 rows were empty and each one went into the average as a zero. =AVERAGE(B2:.B1000*C2:.C1000) used only the 6 real rows and returned 200, which is the right answer. A whole column would be far worse, because B:B is 1,048,576 rows.
Spilling functions show the same problem in a different way. With six rows of site names in column A, using three different names, =UNIQUE(A:A) gave back 5 results, because the header and a 0 for the empty cells came along with the three sites. =UNIQUE(A2:A1000) gave 4, and =UNIQUE(A2:.A1000) gave exactly 3.
Which cells stop the trim even though they look empty?
A trim reference decides where your data ends by looking for content, and it does not care what you can see on screen. So a cell that looks empty to you can still hold the range open, and a cell that looks busy can still count as empty. I put different things under the amounts one at a time and watched where the trimmed range ended.
| What was below the data | Did the range reach it? |
|---|---|
| A cell cleared with Delete | No, it was trimmed away |
| Only a fill colour, a number format or a border | No, it was trimmed away |
A formula ="" in row 20 | Yes, the range ran down to row 20 |
| A single space in row 30 | Yes, down to row 30 |
| A lone apostrophe in row 31 | Yes, down to row 31 |
| A text note in row 900 | Yes, down to row 900 |
The number 999 in row 1500, past the end of B2:.B1000 | No, it was never counted |
The formatting result is useful to know. Microsoft's page on the last cell on a worksheet says Ctrl+End goes to the last cell that contains data or formatting, and in my test Excel's used range did grow down to the formatted cells. The trim reference still ended in the right place.
For a SUM, none of the text changes the answer, and my total stayed at 670 with the note sitting in row 900. For UNIQUE, an average or anything that spills, it does change the answer, because the range now carries hundreds of empty rows down to that note. A stray space far below the data is the first thing I look for when a range runs too long, and it is the kind of leftover I clear when cleaning messy Excel data.
Why does a column filled down with IF formulas never trim?
A very common layout is a helper column filled down in advance, so it is ready when data arrives. Something like =IF(B2="","",B2*2) copied from row 2 to row 1000. It looks empty below the data, but every one of those cells holds a formula, and a formula returning an empty string still counts as content.
In my test, =ROWS(TRIMRANGE(C1:C1000)) on that column returned 1000, so the trim removed nothing, and C:.C gave the same. The accepted answer to the same question on Microsoft's Q&A forum says TRIMRANGE only excludes cells that hold neither a value nor a formula.
The fix is to delete the filled-down column and write one formula in its top cell that spills down on its own, pointed at the column people type into, like =B2:.B1000*2. In my sheet that spilled 7 rows, and when I typed a new amount underneath, it grew to 8 without me touching it. Point the trim at the column people type into, never at a column full of formulas.
Why does a trim reference break when the total sits under the data?
The most common sheet of all has the numbers running down a column and the total right underneath them. It is also the layout where the trim reference lets you down, in two ways depending on how you write it.
The first way is =SUM(B:.B) typed into B9. Column B includes B9 itself, so the formula is trying to add up its own answer, which Excel calls a circular reference. In my test Excel flagged B9 as circular and the total showed 0.
The second way looks safer. =SUM(B2:.B8) in B9 has no circular reference and correctly showed 600. But when I inserted a new row right above the total and typed 70 into it, the formula stayed as =SUM(B2:.B8) and the total stayed at 600. The new row landed just below the end of the range, and a trim only ever makes a range shorter, so nothing pulled that row in. A plain =SUM(B2:B8) did exactly the same thing.
How does a Table total row fix it?
A Table keeps track of where its own data ends, so it does not need a trimmed range at all. Select the data, choose Insert and then Table, and on the Table Design tab tick Total Row. Microsoft's page on totalling the data in an Excel table explains that the total row uses the SUBTOTAL function by default.
In my test the total row wrote =SUBTOTAL(109,[Amount]) and showed 600. I added a row inside the table, typed 70, and the total moved to 670 without me touching the formula. For adding rows at the bottom, Microsoft's page on how to resize a table says that when you start typing in the cell just below the last table row, the table expands to include it.
The 109 tells SUBTOTAL to skip rows hidden by a filter or by hand, so a filtered table totals only what you can see. That is also why a total can disagree with a program that reads every row, which I went through in checking whether ChatGPT or Copilot got your Excel numbers right.
If you would rather not use a Table, move the total above the header instead. With the total in B1, the header in B2 and the amounts starting in B3, I wrote =SUM(B3:.B5000) and there was no circular reference. It showed 600, went to 670 when I typed a new amount underneath, and went to 700 when I inserted another row at the bottom and filled it.
What happens when someone opens the file in an older Excel?
Microsoft lists TRIMRANGE for Excel for Microsoft 365. That starts to matter the moment your file leaves your own PC, because the person opening it may be on Excel 2021 or Excel 2024, the versions you buy once instead of by subscription.
An .xlsx file is really a zip folder of XML files, so I unzipped my saved test workbook and read the formulas inside. =SUM(B2:.B1000) is stored as SUM(_xlfn._TRO_TRAILING(B2:B1000)), and TRIMRANGE is stored as _xlfn.TRIMRANGE. The _xlfn part is the prefix Excel puts in front of newer functions, and Xelplus reports that Excel 2019, 2021 and 2024 show #NAME? for TRIMRANGE instead of a result.
So for a file that goes to a client or to another company, the Table is the safer choice, because Microsoft lists the table total row for Excel 2021 and Excel 2024 as well. It is the same version question I ask when an AI writes an Excel formula for me, because a function the other person's Excel does not have turns a good total into an error.
Which fix should you use for your sheet?
I pick the fix by where the total sits and who opens the file, not by which feature is newest. These cases cover most of the sheets I see.
| Your sheet | Use this | Why |
|---|---|---|
| The total is in another column, on another sheet or on a dashboard | =SUM(B2:.B5000) or =SUM(B:.B) | New rows count and the empty rows are cut off |
| The formula works row by row or spills, like UNIQUE or an average of amount times price | A trim reference on every range | Empty rows stop turning into zeros and extra results |
| The total sits right under the data in the same column | A Table with a total row | A trim reference there is circular or misses inserted rows |
| The file goes to people on Excel 2021 or 2024 | A Table | Trim references show #NAME? there |
| A helper column filled down with IF formulas | One spilling formula over the input column | Filled-down formulas count as content, so nothing trims |
| An old OFFSET and COUNTA dynamic range | A trim reference or a Table | Every blank cell drops a row from the bottom |
A daily tracker is where this bites hardest, because someone adds a row every evening and nobody rereads the formulas, which is the setup in an end of day sales report. In a sheet like that I would put the entries in a Table from day one, and keep trim references for any sheet that reads a plain export.
So check where your total sits. If it is not under the numbers, write the range with a dot, like B2:.B5000. If it is right under the numbers, or the file goes to someone on Excel 2021 or 2024, use a Table with a total row.
A range that misses new rows is a fixed address that nobody moved. Excel for Microsoft 365 now lets you write that address with a dot, like B2:.B5000, so it stops at your last filled row and moves down on its own. In my tests it fixed a total kept in another cell, and it fixed the averages and UNIQUE results that a big fixed range had filled with zeros.
It is not a fix for every sheet. A total under the data in the same column and a file opened in Excel 2021 or 2024 both need a Table with a total row, and a filled-down column of IF formulas needs one spilling formula instead. If you still have an OFFSET and COUNTA dynamic range somewhere, replace that first, because one blank cell is enough to make it drop your newest row.
Sources: Microsoft Support, TRIMRANGE function; Microsoft Support, Total the data in an Excel table; Microsoft Support, Resize a table by adding or removing rows and columns in Excel; Microsoft Support, Locate and reset the last cell on a worksheet; Microsoft Q&A, Does TRIMRANGE take cells with a formula in as having a value; Xelplus, TRIMRANGE in Excel. Every result on this page was tested in Excel for Microsoft 365, version 16.0 build 20326, on 16 September 2026.
