11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: Manipulating Text 141<br />

The formula that follows is a much shorter way to extract the middle name. This formula is useful<br />

if you use the other formulas to extract the first name and the last name. It assumes that the first<br />

name is in B1 and the last name is in D1.<br />

=IF(LEN(B1&D1)+2>=LEN(A1),””,MID(A1,LEN(B1)+2,LEN(A1)-LEN(B1&D1)-2)<br />

As you can see in Figure 5-6, the formulas work fairly well. There are a few problems, however —<br />

notably names that contain four “words.” But, as I mentioned earlier, you can clean these cases<br />

up manually.<br />

If you want to know how I created these complex formulas, refer to Chapter 20 for a<br />

discussion of megaformulas.<br />

Figure 5-6: This worksheet uses formulas to extract the first name, middle name (or initial), and last name<br />

from a list of names in column A.<br />

Removing titles from names<br />

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

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

=IF(OR(LEFT(A1,2)={“Mr”,”Dr”,”Ms”}),RIGHT(A1,LEN(A1)-(FIND(“.”,A1)+1)),A1)

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

Saved successfully!

Ooh no, something went wrong!