| Scenario | Formula | Remarks |
|---|---|---|
| Trimming a Large Range | =TRIMRANGE(G:J) | trims the range G:J, removing empty rows and columns, and returns the trimmed range as an array. |
| Counting Rows of Data | =ROWS(TRIMRANGE(G:J)) | counts the rows in the trimmed range G:J |
| Formula for Counting Rows Excluding Header | =ROWS(DROP(TRIMRANGE(G:J),1)) | |
| Dynamic Sum Formula | =SUM(TRIMRANGE(A1:A100)) | sums the values in the trimmed range A1:A100 |
| Trimming Trailing Rows | =TRIMRANGE(A1:A100, 2) | |
| Leading and Trailing Rows | =TRIMRANGE(A1:A100, 3) |
The TRIMRANGE function automatically removes empty rows and columns from a range of data. It returns a reference that adjusts dynamically. It's particularly useful for:
Note: TRIMRANGE only removes empty rows and columns from the outer edges of the range, not from within the data.