11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

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

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

128<br />

Part II: Using Functions in Your <strong>Formula</strong>s<br />

Removing excess spaces and nonprinting characters<br />

Often data imported into an Excel worksheet contains excess spaces or strange (often unprintable)<br />

characters. Excel provides you with two functions to help whip your data into shape: TRIM<br />

and CLEAN:<br />

TRIM removes all leading and trailing spaces, and it replaces internal strings of multiple<br />

spaces by a single space.<br />

CLEAN removes all nonprinting characters from a string. These “garbage” characters<br />

often appear when you import certain types of data.<br />

This example uses the TRIM function. The formula returns Fourth Quarter Earnings (with no<br />

excess spaces):<br />

=TRIM(“ Fourth Quarter Earnings “)<br />

Counting characters in a string<br />

The Excel LEN function takes one argument and returns the number of characters in the argument.<br />

For example, assume that cell A1 contains the string September Sales. The following formula<br />

returns 15:<br />

=LEN(A1)<br />

Notice that space characters are included in the character count. This can be useful for identifying<br />

strings with extraneous spaces — which can cause problems in some situations, such as in<br />

lookup formulas. The following formula returns FALSE if cell A1 contains any leading spaces, trailing<br />

spaces, or multiple spaces.<br />

=LEN(A1)=LEN(TRIM(A1))<br />

The following formula shortens text that is too long. If the text in A1 is more than ten characters<br />

in length, this formula returns the first nine characters plus an ellipsis (133 on the ANSI chart) as a<br />

continuation character. If it’s ten or fewer, the whole string is returned:<br />

=IF(LEN(A1)>10,LEFT(A1,9)&CHAR(133),A1)<br />

Later in this chapter you’ll see example formulas that demonstrate how to count the<br />

number of a specific character within a string (see the “Advanced Text <strong>Formula</strong>s” section).<br />

Also, Chapter 7 contains additional counting techniques. Still more counting<br />

examples are provided in Chapter 15, which deals with array formulas.

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

Saved successfully!

Ooh no, something went wrong!