ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Dynamic arrays
  3. TRIMRANGE Function in Excel: Drop Empty Rows From a Range

TRIMRANGE Function in Excel: Drop Empty Rows From a Range

By ExcelReady Team·Updated November 3, 2026·6 min read

The short answer

TRIMRANGE removes empty rows and columns from the outer edges of a range, so =UNIQUE(TRIMRANGE(A2:A1000)) only looks at the rows that hold data. It does not remove blank rows in the middle: use FILTER for that. TRIMRANGE and the shorter trim reference A2:.A1000 are recent Microsoft 365 features.

Key takeaways

  • TRIMRANGE(range, [trim_rows], [trim_cols]) cuts empty rows and columns from the edges of a range.
  • It only trims leading and trailing blanks. Blank rows inside the data stay; FILTER removes those.
  • Trim references are a shortcut: A2:.A1000 trims trailing blanks, like TRIMRANGE(A2:A1000,2).
  • It is useful with UNIQUE, SORT and whole-column references, which otherwise pick up empty cells.
  • TRIMRANGE is a recent Microsoft 365 addition; in other versions, use FILTER or an Excel table.
On this page+
  1. What problem does TRIMRANGE solve?
  2. TRIMRANGE syntax
  3. How to use trim references like A:.A
  4. TRIMRANGE does not remove blanks in the middle
  5. When to use TRIMRANGE vs FILTER vs a table
  6. Which Excel versions have TRIMRANGE?
  7. Common TRIMRANGE mistakes
  8. Practise it

The TRIMRANGE function in Excel removes empty rows and columns from the outer edges of a range, so formulas only see the part that holds data. Write =TRIMRANGE(A2:A1000) and, if data fills A2:A6, you get A2:A6. It is useful whenever you point a formula at a big range "to leave room for new rows" and then get zeros or blanks in the result. This guide covers the syntax, the shorter trim references, what TRIMRANGE does not do, and what to use in older versions.

What problem does TRIMRANGE solve?#

Many people use oversized ranges, such as A2:A1000 or the whole column A:A, so new rows are included without editing the formula. With dynamic array functions, that creates problems:

  • UNIQUE returns an extra 0. The empty cells count as one more "unique" value, shown as 0.
  • SORT puts blanks or zeros in the result, and the spill is far longer than the data.
  • Whole-column formulas do extra work, because Excel has to consider up to 1,048,576 rows.

TRIMRANGE fixes this by cutting the empty edge off the range before the other function sees it. The guide to dynamic arrays in Excel explains spilling, and the modern Excel functions lesson lets you practise UNIQUE, SORT and FILTER.

TRIMRANGE syntax#

TRIMRANGE has one required argument and two optional ones:

Excel formula
=TRIMRANGE(range, [trim_rows], [trim_cols])
ArgumentWhat it means
rangeThe range to trim, such as A2:A1000 or A:C
trim_rows0 = keep all rows, 1 = trim leading blank rows, 2 = trim trailing blank rows, 3 = trim both (default)
trim_colsThe same choices for columns; default 3

With these regions in column A:

A
1Region
2North
3South
4North
5East
6South
7
8
9

=UNIQUE(A2:A9) returns North, South, East and 0: four rows, one of them the blank. =UNIQUE(TRIMRANGE(A2:A9)) returns just North, South and East, because the range is trimmed to A2:A6 first.

TRIMRANGE treats a cell as empty only if it is truly empty. A cell with a space, or a formula that returns "", counts as data and is not trimmed.

How to use trim references like A:.A#

Trim references are a shorter way to write the same thing. You add a dot next to the colon of a normal range:

ReferenceTrimsSame as
A2:.A1000Trailing empty rows and columnsTRIMRANGE(A2:A1000,2,2)
A2.:A1000Leading empty rows and columnsTRIMRANGE(A2:A1000,1,1)
A2.:.A1000BothTRIMRANGE(A2:A1000,3,3)

The trailing version is the one you will use most. =UNIQUE(A2:.A1000) lists each region once with no 0 at the end, and =SORT(A:.A) sorts column A down to the last used cell. Think of the dot as being on the side you want trimmed.

TRIMRANGE does not remove blanks in the middle#

This is the most common misunderstanding. TRIMRANGE only trims the edges of the range. If row 4 were blank between North and East, TRIMRANGE would keep it, because it sits inside the data.

To drop every empty row, wherever it is, use FILTER:

Excel formula
=FILTER(A2:A9,A2:A9<>"")

FILTER keeps only the rows where the condition is TRUE, and <>"" means "not empty". It returns North, South, North, East and South. Combine it with UNIQUE for a clean list, and with ROWS to count it:

Excel formula
=ROWS(UNIQUE(FILTER(A2:A9,A2:A9<>"")))

The result is 3 distinct regions. The FILTER function guide explains each argument, and the article on filtering out blank cells covers more cases, such as rows where any column is empty.

When to use TRIMRANGE vs FILTER vs a table#

Each tool fits a different situation:

SituationBest choice
Data grows at the bottom, no gaps insideTRIMRANGE or a trim reference
Blank rows can appear anywhereFILTER with <>""
You control the data layoutAn Excel table (Ctrl+T on Windows, ⌘T on a Mac)
You need the first or last N rowsTAKE or DROP

Excel tables are often the cleanest answer: a structured reference such as Table1[Region] grows and shrinks with the data, in every version since Excel 2007. TRIMRANGE helps when the data can't be a table, such as a range filled by another process. To return a fixed number of rows instead, see the TAKE function guide.

Which Excel versions have TRIMRANGE?#

TRIMRANGE and trim references are a recent addition to Microsoft 365. They appeared first for Microsoft 365 Insiders and then rolled out to subscribers on Windows, Mac and the web, so a Microsoft 365 install that hasn't updated recently may not have them yet. Perpetual versions such as Excel 2021 don't have them, and as far as Microsoft's version notes show, neither does Excel 2024. To check your own Excel, type =TRIMR in a cell: if TRIMRANGE appears in the list, you have it.

If you share a file with someone on an older version, TRIMRANGE formulas show a #NAME? error on their computer. For shared files, FILTER (Excel 2021 and Microsoft 365) or a table is the safer choice.

Common TRIMRANGE mistakes#

Check these if the result isn't what you expect:

  • Expecting middle blanks to go. TRIMRANGE trims edges only. Use FILTER.
  • "Empty-looking" cells. A space or a "" formula stops the trim. Clear those cells or use FILTER.
  • #SPILL! errors. The trimmed result still spills; make sure the cells below the formula are empty. The guide to referencing a spill range explains the # operator.
  • Writing the dot in the wrong place. A2.:A1000 trims leading blanks, not trailing ones.
  • Using it in a file for older versions. Other people will see #NAME?.

Practise it#

TRIMRANGE is one of several newer functions built for dynamic arrays, and FILTER is the one you will use most. Practise the FILTER function in a live spreadsheet, then practise UNIQUE, SORT and other modern Excel functions: you type the formula and it checks it instantly. Or try the exercise on this page and count the regions without the blank.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

The Region list in A2:A9 has blank rows at the end. =ROWS(UNIQUE(A2:A9)) returns 4, because the blank counts as a region. In C2, count the distinct regions without the blank: wrap A2:A9 in FILTER to keep non-empty cells, then UNIQUE, then ROWS. Press Enter.

fx
ABCD
1
Region
2
North
Distinct regions
3
South
4
North
5
East
6
South
7
8
9

Tip: FILTER(A2:A9,A2:A9<>"") keeps only filled cells. Put that inside UNIQUE, and UNIQUE inside ROWS.

Practise this in a lesson

LessonModern Excel: XMATCH, SORTBY, TEXTSPLIT and spill references (A2#)Split names with TEXTSPLIT, find positions with XMATCH, sort by another column with SORTBY, and refer to a whole spilled result with A2#.LessonFILTER: pull matching rows with a formulaReturn every row that meets one or more conditions with FILTER, and show a friendly message when nothing matches.Function guideFILTERReturn every row that matches a condition with Excel's FILTER. Multiple criteria, empty results and #SPILL! explained, with live practice.

Frequently asked questions

What does the TRIMRANGE function do in Excel?

+

It returns a range with the empty rows and columns at its outer edges removed. For example, if data fills A2:A6, TRIMRANGE(A2:A1000) returns just A2:A6.

Does TRIMRANGE remove blank rows in the middle of data?

+

No. It only trims empty rows and columns at the start and end of the range. To remove every blank row, use FILTER, such as =FILTER(A2:A100,A2:A100<>"").

What does A:.A mean in Excel?

+

It is a trim reference. The dot after the colon trims empty rows from the end of the range, so A:.A means column A down to the last used cell. A.:A trims leading blanks and A.:.A trims both.

Which Excel versions have TRIMRANGE?

+

TRIMRANGE and trim references are a recent addition to Microsoft 365. Older perpetual versions such as Excel 2021 don't have them. If typing =TRIMRANGE( shows no tooltip, your version doesn't support it.

Why does UNIQUE return a 0 at the end of the list?

+

The range includes empty cells, and UNIQUE returns one empty value, which shows as 0. Trim the range with TRIMRANGE, or filter out blanks with FILTER before UNIQUE.

Sources

  • FILTER function - Microsoft Support
  • UNIQUE function - Microsoft Support
  • Dynamic array formulas and spilled array behavior - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What problem does TRIMRANGE solve?
  2. TRIMRANGE syntax
  3. How to use trim references like A:.A
  4. TRIMRANGE does not remove blanks in the middle
  5. When to use TRIMRANGE vs FILTER vs a table
  6. Which Excel versions have TRIMRANGE?
  7. Common TRIMRANGE mistakes
  8. Practise it

Keep reading

Dynamic arrays· 7 min read

Filter Out Blanks in Excel With the FILTER Function

To filter out blanks in Excel, use FILTER with a not-empty test: =FILTER(A2:A10,A2:A10<>""). The condition A2:A10<>"" is TRUE for every cell that holds something, so only those cells spill into the result. For whole rows, filter a wider range on one column. FILTER needs Excel 2021 or Microsoft 365.

Dynamic arrays· 6 min read

Dynamic Arrays in Excel Explained Simply

Dynamic arrays let one Excel formula return several values that spill into the cells below or beside it. Type =UNIQUE(B2:B9) in one cell and the whole list appears, then resizes when the data changes. They need Excel 2021, Excel 2024, Microsoft 365 or Excel for the web. Refer to a whole spill with a # after its first cell, such as E2#.

Dynamic arrays· 6 min read

The FILTER Function in Excel (With AND and OR)

FILTER returns every row of a range that passes a test: =FILTER(A2:C9,B2:B9="East"). The matching rows spill into the cells below and update when the data changes. For AND, multiply tests in brackets; for OR, add them. The third argument shows a message when nothing matches. FILTER needs Excel 2021, Excel 2024 or Microsoft 365.

More on dynamic arrays

  • Get Unique Values From Multiple Columns in Excel
  • The UNIQUE Function in Excel
  • Make a Sorted List of Unique Values in Excel
  • Auto Number Rows in Excel (SEQUENCE and ROW)
  • Count Unique Values With Criteria in Excel
  • Dynamic Drop-Down Lists in Excel That Update Themselves
All dynamic arrays articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free