Microsoft Tech Community - Latest Blogs - Excel Blog

السبت، 20 أغسطس 2022

The TRIM function

 

TRIM

The TRIM function will remove any extra spaces either before or after the cell text as well as remove and redundant spaces within the text.

For example, if we had the following in cell A1:

“     This is      a            test    !           “

We could write the following formula:

=TRIM(A1)

… and get returned “This is a test!”

This is a function to use when you are using VLOOKUP because sometimes the data being searched for has “invisible” spaces at the end that cause havoc with VLOOKUPs ability to perform an accurate match.

If we used the previous VLOOKUP example, we could make the formula more robust by nesting a TRIM function in the first argument like so.

=VLOOKUP(TRIM(A3), G3:H14, 2, False)

Examples of creative uses of the TRIM function can be seen in the following post.

XelPlus – Removing “Stubborn” Spaces in Excel Data

ليست هناك تعليقات:

إرسال تعليق