18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Creating Formulas That Manipulate Text 12<br />

Splitting text strings without using formulas<br />

I<br />

n many cases, you can eliminate the use of formulas and use Excel’s Text To Columns command to parse<br />

strings into their component parts. This command is found in the Data Tools group of the Data tab. The Text<br />

To Columns command displays the Convert Text To Columns Wizard, which consists of a series of dialog<br />

boxes that walk you through the steps to convert a single column of data into multiple columns. Generally,<br />

you want to select the Delimited option (in Step 1) and use Space as the delimiter (in Step 2), as shown in the<br />

following figure.<br />

The formula uses the TRIM function to remove excess spaces. It then uses the SUBSTITUTE function to<br />

create a new string (in memory) that has all the space characters removed. The length of this string is subtracted<br />

from the length of the original (trimmed) string to get the number of spaces. This value is then<br />

incremented by 1 to get the number of words.<br />

Note that this formula will return 1 if the cell is empty. The following modification solves that problem:<br />

=IF(LEN(A1)=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1),” “,””))+1)<br />

221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!