18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

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

Part II<br />

Working with Formulas and Functions<br />

To pad the number with asterisks, use two asterisks in the number-format code, like this:<br />

$#,##0.00**<br />

CROSS-REF<br />

Refer to Chapter 24 for more information about custom number formats, including additional<br />

examples using the asterisk format code.<br />

Removing excess spaces and nonprinting characters<br />

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

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

n<br />

n<br />

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

single space.<br />

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

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

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

spaces):<br />

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

Counting characters in a string<br />

Excel’s LEN function takes one argument and returns the number of characters in the argument. For example,<br />

assume the string September Sales is contained in cell A1. The following formula will return 15:<br />

=LEN(A1)<br />

Notice that space characters are included in the character count.<br />

The following formula returns the total number of characters in the range A1:A3:<br />

=LEN(A1)+LEN(A2)+LEN(A3)<br />

CROSS-REF<br />

You see example formulas that demonstrate how to count the number of specific characters<br />

within a string later in this chapter. Chapter 14 covers counting techniques further.<br />

Changing the case of text<br />

Excel provides three handy functions to change the case of text:<br />

n<br />

n<br />

n<br />

UPPER converts the text to ALL UPPERCASE.<br />

LOWER converts the text to all lowercase.<br />

PROPER converts the text to Proper Case (the first letter in each word is capitalized, as in a proper<br />

name).<br />

These functions are quite straightforward. The formula that follows, for example, converts the text in cell<br />

A1 to proper case.<br />

=PROPER(A1)<br />

If cell A1 contained the text MR. JOHN Q. PUBLIC, the formula would return Mr. John Q. Public.<br />

214

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

Saved successfully!

Ooh no, something went wrong!