The TRIM function removes all spaces from the front and back of the the text string, and all duplicate spaces in the middle. To apply the formula on cell B1, the formula would look like:
Take a look at the TRIM worksheet function in Excel help (simply pull up Help in Excel and type in "TRIM worksheet function").
Excel's Help does a great job with functions, giving detailed explanations and examples. It is a great tool that I use all the time.