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.

Creating Formulas That Manipulate Text 12<br />

Transforming Data with Formulas<br />

Many of the examples in this chapter describe how to use functions to transform data in some way. For<br />

example, you can use the UPPER function to transform text into uppercase. Often, you’ll want to<br />

replace the original data with the transformed data. To do so, use the Paste Special dialog box. Specifically,<br />

follow these steps:<br />

1. Create your formulas to transform the original data.<br />

2. Select the formula cells.<br />

3. Choose Home ➪ Clipboard ➪ Copy (or press Ctrl+C).<br />

4. Select the original data cells.<br />

5. Choose Home ➪ Clipboard ➪ Paste Values.<br />

This procedure replaces the original data with the transformed data; then you can delete the formulas.<br />

These functions operate only on alphabetic characters; they simply ignore all other characters and return<br />

them unchanged.<br />

Extracting characters from a string<br />

Excel users often need to extract characters from a string. For example, you may have a list of employee<br />

names (first and last names) and need to extract the last name from each cell. Excel provides several useful<br />

functions for extracting characters:<br />

n<br />

n<br />

LEFT returns a specified number of characters from the beginning of a string.<br />

RIGHT returns a specified number of characters from the end of a string.<br />

n MID returns a specified number of characters beginning at any position within a string.<br />

The formula that follows returns the last 10 characters from cell A1 (if A1 contains fewer than 10 characters,<br />

the formula returns all text in the cell):<br />

=RIGHT(A1,10)<br />

This next formula uses the MID function to return five characters from cell A1, beginning at character position<br />

2. In other words, it returns characters 2–6.<br />

=MID(A1,2,5)<br />

The following example returns the text in cell A1 with only the first letter in uppercase. It uses the LEFT<br />

function to extract the first character and convert it to uppercase. This then concatenates to another string<br />

that uses the RIGHT function to extract all but the first character (converted to lowercase). Here’s what it<br />

looks like:<br />

=UPPER(LEFT(A1))&RIGHT(LOWER(A1),LEN(A1)-1)<br />

If cell A1 contained the text FIRST QUARTER, the formula would return First quarter.<br />

NOTE<br />

This is different than the result obtained using the PROPER function. The PROPER function<br />

makes the first character in each word uppercase.<br />

215

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

Saved successfully!

Ooh no, something went wrong!