
π This article includes 1 downloadable practice file β
In this article
TRIMRANGE removes empty rows and columns from the outside of a range, so formulas can point at whole columns without processing a million blanks.
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
| Range | Formula | Result |
|---|---|---|
| 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
| Mistake | What to do instead |
|---|---|
| Older Excel | Needs the latest Microsoft 365 |
| Trim refs | A1:.A1000 is the short form |
Related functions
π Part of the free Excel course: Beginner β Expert Β· Try it in the Formula Lab or ask the AI Helper.
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.
Atul (AJ) builds office-automation and local-first AI tools as Atulya AI, and works with Excel, SAP and Oracle EPM every day. He writes about the shortcuts, macros and automations that actually save time β plus the occasional wacky fact. Videos on YouTube: Lazy Automator AI (@LazyAutomatorAI).
More posts by Atul βBuild this skill next
This page is a quick function reference. Use it for syntax, then practise the function in a broader workflow.
Stuck on a step? Ask a question and the AI answers using this article.