Microsoft has announced a timely addition to Excel that removes empty rows from the edges of a range. This means that Excel won’t return thousands of zeros if the calculation references empty cells.

In the example below, we want Excel tocount the number of charactersin each cell in column A by typing the below function into cell B1:

An Excel sheet containing values in column A, and the LEN function in cell B1.

However, when we press Enter, we can see that all the cells from B10 downwards return 0. Not only does this look untidy, but it also means that Excel is making over a million unnecessary calculations, since it has applied this formula to every single cell in column B.

Adding the TRIMRANGE function to the calculation tells Excel to discount any blank cells, essentiallytrimmingthe data to include only the necessary cells:

An Excel sheet containing the LEN calculation beyond the required cells.

​​​​

Now, if we add more values to column A, Excel will automatically extend the LEN function downwards.

The LEN function with TRIMRANGE in Excel.

Excel also lets you be more targeted with your use of TRIMRANGE by using Trim References. Adding a period before and/or after the colon in the reference tells Excel to trim the blanks at the start of the range, end of the range, or both.

Trailing trim (:.)

An Excel sheet containing the LEN function with TRIMRANGE, with two new values added at the bottom of the range to show its function.

Trim trailing blanks

Leading trim (.:)

Trim leading blanks

Full trim (.:.)

A1.:.E10

Trim leading and trailing blanks

This means that you may confidently use full-column references in Excel, something that you might have previously avoided due to theirimpact on your spreadsheet’s performance.

In its current form, you can’t apply TRIMRANGE to blanks in the middle of ranges, only those at the beginning and end.

Currently only available in preview to Microsoft Insider members on the Beta Channel (Version 2409, Build 18020.2000 or later), we can expect Microsoft to roll out this new feature for general use once it is refined based on Insider feedback.