What TRIMRANGE does
TRIMRANGE removes empty rows and columns from the edges of a range. It's useful when a list has room for more entries but you want a formula to return only the occupied part. You choose which edges to trim; the source cells stay where they are.
For a vertical list, use the second argument to control rows and set the third argument to 0 to keep columns. Omitting both optional arguments trims empty edges in both directions.
Practical examples
Remove empty rows above and below a team list
Set up A2:A7 as follows. Leave the cells marked empty genuinely empty; don't type that word or a space into them.
| Cell | Contents |
|---|---|
| A2 | empty |
| A3 | Design |
| A4 | Finance |
| A5 | Support |
| A6 | empty |
| A7 | empty |
With C3:C5 clear, enter this in C3:
=TRIMRANGE(A2:A7,3,0)FormulaThe expected result fills C3:C5:
Design
Finance
SupportExampleThe 3 removes empty rows at both ends: A2 above the list, and A6:A7 below it. The 0 leaves the column dimension alone.
Keep a fixed starting row and trim the unused tail
Use the same data, but start the source at A3, where the first team name belongs. With E3:E5 clear, enter this in E3:
=TRIMRANGE(A3:A7,2,0)FormulaThe expected result fills E3:E5:
Design
Finance
SupportExampleThe 2 removes only trailing empty rows. Excel starts at the bottom of A3:A7, excludes A7 and A6, and keeps A3:A5. If the first source row becomes empty, this setting won't trim it from the top.
The updating a list without OFFSET tutorial uses this trailing-row setting in a defined name for a bounded drop-down source, with the setup and tested-build limits explained beside the formula.
Common mistakes and notes
Internal gaps stay in the range
TRIMRANGE trims the outside of a range; it doesn't remove individual empty cells between entries. Clearing A4 in the examples leaves a position between Design and Support. Use a filtering operation if your task requires a compact list with those gaps removed.
A cell that looks empty may contain something
The examples use cells with no contents. A space and a formula returning "" are different inputs. In the linked tutorial's tested named drop-down source, either one at the trailing edge kept an extra visually blank choice. Clear the cell's contents when you want a genuinely empty trailing cell.
The source boundary still matters
Both examples stop at A7. An entry added in A8 is outside those references and won't appear in their results. Allow enough room in the source range for the entries you expect, or use a Table-based approach when the source itself needs to expand.
Leave room for the result and check availability
The worksheet examples return three rows into neighboring cells, so keep the output area clear. Microsoft's current Applies To list names Excel for Microsoft 365. Check that your Excel recognizes TRIMRANGE before using it in a shared workbook; the linked drop-down tutorial records the specific Mac build tested for that method.