Microsoft Office Tutorials and References

In Depth Information

**Using Operators in Formulas**

Nested parentheses

You can also
nest
parentheses in formulas — that is, put parentheses inside of parentheses. When

a formula contains nested parentheses, Excel evaluates the most deeply nested expressions first

and works its way out. The following example of a formula uses nested parentheses:

=((B2*C2)+(B3*C3)+(B4*C4))*B6

This formula has four sets of parentheses. Three sets are nested inside the fourth set. Excel

evaluates each nested set of parentheses and then sums the three results. This sum is then multiplied

by the value in B6.

It’s a good idea to make liberal use of parentheses in your formulas even when they aren’t

necessary. Using parentheses clarifies the order of operations and makes the formula easier to read.

For example, if you want to add 1 to the product of two cells, the following formula does the job:

=A1*A2+1

Because of Excel’s operator precedence rules, the multiplication will be performed before the

addition. Therefore, parentheses are not necessary. You may find it much clearer, however, to use

the following formula even though it contains superfluous parentheses:

=(A1*A2)+1

Every left parenthesis, of course, must have a matching right parenthesis. If you have

many levels of nested parentheses, you may find it difficult to keep them straight.

Fortunately, Excel lends a hand in helping you match parentheses. When editing a

formula, matching parentheses are colored the same, although the colors can be difficult

to distinguish if you have a lot of parentheses. Also, when the cursor moves over a

parenthesis, Excel momentarily displays the parenthesis and its matching parenthesis in

bold. This lasts for less than a second, so watch carefully.

In some cases, if your formula contains mismatched parentheses, Excel may propose a correction

to your formula. Figure 2-2 shows an example of Excel’s AutoCorrect feature in action.