Microsoft Office Tutorials and References

In Depth Information

The preceding 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.

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. There-

fore, 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. For-

tunately, 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 dis-

tinguish if you have a lot of parentheses. Also, when the cursor moves over a paren-

thesis, 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 for-

mula. Figure 2-3 shows an example of Excel's AutoCorrect feature in action.

Simply accepting the correction proposed in the dialog box is tempting, but be careful.

In many cases, the proposed formula, although syntactically correct, isn't the formula

that you want. In the following example, I omitted the closing parenthesis after January.

In Figure 2-3, Excel proposed this correction:

=SUM(January/SUM(Total)

In fact, the correct formula is

=SUM(January)/SUM(Total)