1. Home
  2. Functions
  3. Array
  4. TRIMRANGE

TRIMRANGE function

Removes empty rows and columns from the edges of a range.

Syntax

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

Arguments

ArgumentRequiredDescription
rangeRequiredThe range to trim
trim_rowsOptional0 none, 1 leading, 2 trailing, 3 both (default)
trim_colsOptional0 none, 1 leading, 2 trailing, 3 both (default)

How to use TRIMRANGE

When TRIMRANGE returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.

TRIMRANGE takes 1 required argument and 2 optional arguments. Type =TRIMRANGE( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.

Examples

Each result below was calculated by the SheetsBat formula engine.

=TRIMRANGE(A1:C5)Result 2 by 2 array
Data in the sheet
AB
21
32
Spilled result
AB
110
202
=ROWS(TRIMRANGE(A1:A10))Result 3
Data in the sheet
A
31
4
52

Every formula, right in your browser

SheetsBat calculates 536 functions, with charts, pivot tables and live collaboration. Free to start.