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 />

This formula will return either TRUE of FALSE. However, Excel is a bit lax in its comparisons when text is<br />

involved. Consider the case in which A1 contains the word January (initial capitalization), and A2 contains<br />

JANUARY (all-uppercase). You’ll find that the previous formula returns TRUE, even though the contents<br />

of the two cells are not really the same — the comparison is not case-sensitive.<br />

Often, you don’t need to worry about the case of the text. But if you need to make an exact, case-sensitive<br />

comparison, you can use the EXACT function. The formula that follows returns TRUE only if cells A1 and<br />

A2 contain exactly the same entry:<br />

=EXACT(A1,A2)<br />

When you compare text, be careful with space characters — which are often difficult to spot. The following<br />

formula returns FALSE because the first string contains a trailing space:<br />

=EXACT(“Canada “,”Canada”)<br />

Joining two or more cells<br />

Excel uses an ampersand (&) as its concatenation operator. Concatenation is simply a fancy term that<br />

describes what happens when you join the contents of two or more cells. For example, if cell A1 contains<br />

the text Tucson and cell A2 contains the text Arizona, the following formula will return<br />

TucsonArizona:<br />

=A1&A2<br />

Notice that the two strings are joined together without an intervening space. To add a space between the<br />

two entries (to get Tucson Arizona), use a formula like this one:<br />

=A1&” “&A2<br />

Or, even better, use a comma and a space to produce Tucson, Arizona:<br />

=A1&”, “&A2<br />

If you’d like to force the second string to be on a new line, concatenate the strings using CHAR (10), which<br />

inserts a line-break character. Also, make sure that you apply the Wrap Text format to the cell. The following<br />

example joins the text in cell A1 and the text in cell B1, with a line break in between:<br />

TIP<br />

=A1&CHAR(10)&B1<br />

To apply Wrap Text formatting, select the cells and then use Home ➪ Alignment ➪ Wrap Text.<br />

Here’s another example of the CHAR function. The following formula returns the string Stop by concatenating<br />

four characters returned by the CHAR function:<br />

=CHAR(83)&CHAR(116)&CHAR(111)&CHAR(112)<br />

Here’s a final example of using the & operator. In this case, the formula combines text with the result of an<br />

expression that returns the maximum value in column C:<br />

NOTE<br />

=”The largest value in Column C is “ &MAX(C:C)<br />

Excel also has a CONCATENATE function, which takes up to 255 arguments. For example:<br />

=CONCATENATE(A1,B1,C1,D1)<br />

This function simply combines the arguments into a single string. You can use this function if you like, but<br />

using the & operator results in shorter formulas.<br />

210

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

Saved successfully!

Ooh no, something went wrong!