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.

Part II<br />

Working with Formulas and Functions<br />

FIGURE 12.5<br />

This worksheet uses formulas to extract the first name, last name, and middle name (or initial) from a list of names in<br />

column A.<br />

Removing titles from names<br />

You can use the formula that follows to remove three common titles (Mr., Ms., and Mrs.) from a name. For<br />

example, if cell A1 contains Mr. Fred Munster, the formula would return Fred Munster.<br />

=IF(OR(LEFT(A1,2)=”Mr”,LEFT(A1,3)=”Mrs”,LEFT(A1,2)=”Ms”),<br />

RIGHT(A1,LEN(A1) -FIND(“ “,A1)),A1)<br />

Creating an ordinal number<br />

An ordinal number is an adjective form of a number. Examples include 1st, 2nd, 5th, 23rd, and so on.<br />

The formula that follows displays the value in cell A1 as an ordinal number:<br />

=A13&IF(OR(VALUE(RIGHT(A1,2))={11,12,13}),”th”,<br />

IF(OR(VALUE(RIGHT(A1))={1,2,3}),CHOOSE(RIGHT(A1),<br />

“st”,”nd”,”rd”),”th”))<br />

The formula is rather complex because it must determine whether the number will end in th, st, nd, or<br />

rd. This formula also uses literal arrays (enclosed in brackets), which are described in Chapter 17.<br />

Counting the number of words in a cell<br />

The following formula returns the number of words in cell A1:<br />

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

220

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

Saved successfully!

Ooh no, something went wrong!