How can I remove ONLY leading and trailing spaces while leaving spaces in between words alone with an excel formula?
<p>In excel, <code>TRIM()</code> will remove all spaces before and after text, while also removing any duplicate spaces in between words.</p>

<p>Is there a formula or combination thereof that will do the same as <code>TRIM()</code> but leave spaces between words as-is?</p>

<p>In the following example, I'm looking for a formula that will accomplish that of the fictitious formula "WXYZ":</p>

<p><code>TRIM("  Omicron   Persei 8  ")</code> = <code>"Omicron Persei 8"</code><br>
<code>WXYZ("  Omicron   Persei 8  ")</code> = <code>"Omicron   Persei 8"</code></p>

<p>Note that I've read somewhere that <code>TRIM()</code> in VBA will work like that of WXYZ above. However, I'm looking for a formula solution.</p>