Delete Trailing Spaces In Excel

These trailing spaces cause the VLOOKUP to not classify the cells as a match. Although you can tell that ' BG33-8 ' is the same as ' BG33-9', Excel cannot. Column A has trailing spaces. You can use the TRIM function to remove leading and trailing spaces from a value. The TRIM function in Excel removes leading spaces, extra spaces and trailing spaces. Use the SUBSTITUTE function to remove all spaces or non-breaking spaces. The TRIM function below removes 2 leading spaces, 3 extra spaces and 2 trailing spaces. Note: the TRIM function does not remove single spaces between words.

The TRIM function in Excel removes leading spaces, extra spaces and trailing spaces. Use the SUBSTITUTE function to remove all spaces or non-breaking spaces.

1. The TRIM function below removes 2 leading spaces, 3 extra spaces and 2 trailing spaces.

Note: the TRIM function does not remove single spaces between words.

2. To get the length of a string, use the LEN function.

Explanation: the LEN function counts 2 spaces, 2 characters, 4 spaces, 3 characters and 2 spaces.

3. You can use the SUBSTITUTE function to remove all spaces.

Note: the SUBSTITUTE function substitutes spaces (second argument) with empty strings (third argument).

Text imported from other applications may contain ASCII characters. The CLEAN function removes the first 32 non-printable ASCII characters (codes 0 through 31).

4. The CLEAN function below removes a non-printable character, CHAR(7).

5. Simply combine CLEAN and TRIM to remove non-printable characters and spaces.

6. The CLEAN function removes line breaks. To enter a line break, press ALT + ENTER.

Trailing

How To Delete Trailing Spaces In Excel

7. You can also use the SUBSTITUTE function to remove a line break, CHAR(10), and replace it with something else. For example, a comma and a space.

The CLEAN function doesn't remove all ASCII characters. Simply use the SUBSTITUTE function to remove other ASCII characters.

8. First, find out the code number of the character.

9. Next, use SUBSTITUTE and CHAR to return the text string without this character.

Trim Trailing Spaces In Excel

10. If your text contains non-breaking spaces, CHAR(160), the TRIM function doesn't work.

Delete Trailing Spaces In Excel Vba

11. You can use the SUBSTITUTE function to substitute non-breaking spaces, CHAR(160) with normal spaces, CHAR(32). Don't forget to add a TRIM function to remove the extra spaces.