April 24, 2010

Removing unwanted Spaces at the beginning or end of a string of text

When dealing with large amounts of text-based data (e.g., names, addresses, etc.), it is likely that there are lots of spaces before or after many of the words. These spaces can represent a problem if you want to, for example, sort the data properly, use it in graphs, or combine it.

To solve this problem, use the TRIM() function. The trim function removes leading, trailing or extra spaces in data.

For example:
=TRIM(A3)   (note: this would remove any unwanted spaces before, within, or after the text in cell A3).

Thankfully, this function removes the extra spaces at the beginning and end of a string of text, but it does NOT remove the spaces between bits of text. For example, the name "Adam Smith" will not become "AdamSmith" when using TRIM().

The trim function will remove the extra speces between bits of text. For example "  Adam     Smith  " will be trimmed to "Adam Smith"

To replace all spaces even the ones between names, then use the Replace feature (Ctrl and H)(replace the space with nothing).

Video:



Video:

Followers