TRIMRANGE Function in Excel: Cut Empty Edges Off a Range

TRIMRANGE Function in Excel: Cut Empty Edges Off a Range featured illustration

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 5 October 2026

Dynamic ArrayLevel: ExpertAvailable in: Excel 365 / 2021+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. TRIMRANGE in practice
  5. Where you will use it
  6. Worked example
  7. Mistakes people make
  8. Related functions
  9. Continue learning

TRIMRANGE removes empty rows and columns from the outside of a range, so formulas can point at whole columns without processing a million blanks.

Advertisement

Syntax

=TRIMRANGE(range, [trim_rows], [trim_cols])
Argument What it means
trim_rows 0 none, 1 leading, 2 trailing, 3 both (default).

Examples

Example 1

=UNIQUE(TRIMRANGE(A:A))

Unique values from a column that keeps growing.

TRIMRANGE in practice

Where you will use it

  • Ignore empty rows at the bottom of a range
  • Dynamic ranges without OFFSET
  • Faster whole-column formulas

Worked example

RangeFormulaResult
A1:A1000 with 25 filled rows=ROWS(TRIMRANGE(A1:A1000))25
B:B with 3 filled rows=ROWS(TRIMRANGE(B:B))3
C1:C10 all filled=ROWS(TRIMRANGE(C1:C10))10

Worked out step by step, not calculated here: TRIMRANGE needs the latest Microsoft 365.

Mistakes people make

MistakeWhat to do instead
Older ExcelNeeds the latest Microsoft 365
Trim refsA1:.A1000 is the short form

DROP Β· FILTER

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Dynamic arrays18 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 35 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *