Check it out.

Use the Microsoft Excel TRIM Function to Remove Extra Spaces

Some people get a little overexcited with the space bar when entering data. Things get worse when you copy and paste them in. To get rid of those pesky extra spaces, use the TRIM function.

Use the Microsoft Excel SUBSTITUTE Function to Remove Special Characters

Trimming is all well and good. But what if some goofball put line breaks into your Excel spreadsheet? Or what if you want to get rid of ALL the spaces? You can do that using SUBSTITUTE. The syntax for SUBSTITUTE is: Got that? I’m glad you asked. Just type ” “. Like this: In this function, you’re substituting a space with nothing. Nice.

To type something really weird, like a line break, you have to use CHAR(). This lets you pick a specific character that can’t be typed into a formula. The character number for a line break is 10. So, you’d do this:

The optional [instance_num] argument lets you remove say, just the first or second instance of the old text. For example:

You can also nest SUBSTITUTE functions. For example, if you wanted to parse the special characters out of a bunch of phone numbers:

CHAR() and CODE() ANSI/ASCII Code Reference

The trick to SUBSTITUTE() is memorizing every single number to plug into CHAR(). It took me all afternoon, but I’ve finally committed every ANSI character code to memory. Just kidding. I can’t even remember how old I am let alone what the ANSI code for a space or the @ sign is. Fortunately, you don’t need to. You can either print off this chart from MSDN or use the CODE() Excel function to look up character codes on the fly.

Think of CODE() as the opposite of CHAR().

Conclusion

And there’s your Excel tip for the day. Happy trimming and substituting! Comment Name * Email *

Δ  Save my name and email and send me emails as new comments are made to this post.

Excel Tip  Remove Spaces and Line Breaks from Cells - 71Excel Tip  Remove Spaces and Line Breaks from Cells - 39Excel Tip  Remove Spaces and Line Breaks from Cells - 24Excel Tip  Remove Spaces and Line Breaks from Cells - 27Excel Tip  Remove Spaces and Line Breaks from Cells - 21Excel Tip  Remove Spaces and Line Breaks from Cells - 88Excel Tip  Remove Spaces and Line Breaks from Cells - 98Excel Tip  Remove Spaces and Line Breaks from Cells - 55