Skip to content
ExcelExcel Microsoft 365+

TRIMRANGE function in Excel

Scans in from the edges of a range or array until it finds a non-blank cell (or value), it then excludes those blank rows or columns

=TRIMRANGE(range, [trim_rows], [trim_cols])

TRIMRANGE syntax and parameters

Three arguments, one required.

  • rangerangeRequired

    The range (or array) to be trimmed

  • trim_rowsnumberOptional

    Determines which rows should be trimmed0 - None1 - Trims leading blank rows2 - Trims trailing blank rows3 - Trims both leading and trailing blank rows (default)

  • trim_colsanyOptional

TRIMRANGE examples

Formulas you'll actually reuse.

  1. Sort the used part of a padded range — no trailing blank rows in the spill:

    =SORT(TRIMRANGE(A2:C1000), 3, -1)
  2. A whole-column reference cut down to its used rows (2 = trailing blanks only), ready for FILTER or UNIQUE:

    =TRIMRANGE(A:C, 2)

TRIMRANGE in Google Sheets

No direct equivalent — here's the way around.

Try TRIMRANGE in the playground

Edit the example — nothing to install.

Preloaded with the TRIMRANGE formula from Example 1 — change anything and watch it respond.

Loading the editor…

TRIMRANGE errors

What they mean — and the fixes.

  • #VALUE!

    trim_rows and trim_cols accept only 0–3 (none, leading, trailing, both).