Lookup and referenceMicrosoft 365

TRIMRANGE

Remove blank outer rows or columns so the result fits the populated area.

Syntax

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

Worked example

Enter 7 in B2 and 9 in C3, leaving all other cells in A1:D5 empty. Put the formula outside that range. Only the occupied rectangle B2:C3 remains.

=TRIMRANGE(A1:D5)

Result 2 rows × 2 columns

Microsoft documentation

Check the arguments, supported editions and behavior of this function in Microsoft’s reference.

Microsoft reference

Search ExcelTutor