


SUBSTITUTE is used to replace each space (” “) with a comma and space (“, “). It takes care of extra spaces caused by empty cells. TRIM automatically strips space at the start and end of a given string and leaves just one space between all words inside the string. The TRIM function is used to “normalize” all spacing. The formula first joins the values in the four cells to the left using the concatenation operator (&) and a single space between each value. To join multiple cell values with a comma, we can use a formula based on the SUBSTITUTE and TRIM functions. The above formula removes all leading and trailing spaces, if any, and turns the resulting value into a number, as shown below: To fix this, we will use the VALUE function along with the TRIM function, instead of the above formula: Using the TRIM function, we will get the following result:Īs you can see above, the trimmed values are text strings, while we want numbers.

Let us see how the TRIM function works for numbers. Suppose we are given the following data from an external source:įor trimming the spaces, we will use the following function: To understand the uses of the function, let’s consider a few examples: Example 1 TRIM is a built-in function that can be used as a worksheet function in Excel.

