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

Using Advanced Excel Features<br />

Notice that the negation operator symbol is exactly the same as the subtraction operator symbol. This, as<br />

you may expect, can cause some confusion. Consider these two formulas:<br />

=-3^2<br />

=0-3^2<br />

The first formula, as expected, returns 9. The second formula, however, returns –9. Squaring a number<br />

always produces a positive result, so how is it that Excel can return the –9 result?<br />

In the first formula, the minus sign is a negation operator and has the highest precedence. However, in the<br />

second formula, the minus sign is a subtraction operator, which has a lower precedence than the exponentiation<br />

operator. Therefore, the value 3 is squared, and the result is subtracted from zero, which produces a<br />

negative result.<br />

Using parentheses, as shown in the following formula, causes Excel to interpret the operator as a minus sign<br />

rather than a negation operator. This formula returns –9.<br />

=-(3^2)<br />

Formulas are not calculated<br />

If you use custom worksheet functions written in VBA, you may find that formulas that use these functions<br />

fail to get recalculated and may display incorrect results. To force a single formula to be recalculated, select<br />

the cell, press F2, and then press Enter. To force a recalculation of all formulas, press Ctrl+Alt+F9.<br />

Actual versus displayed values<br />

You may encounter a situation in which values in a range don’t appear to add up properly. For example,<br />

Figure 32.3 shows a worksheet with the following formula entered into each cell in the range B3:B5:<br />

=1/3<br />

FIGURE 32.3<br />

A simple demonstration of numbers that appear to add up incorrectly.<br />

Cell B6 contains the following formula:<br />

=SUM(B3:B5)<br />

All the cells are formatted to display with three decimal places. As you can see, the formula in cell B6<br />

appears to display an incorrect result. (You may expect it to display 0.999.) The formula, of course, does<br />

return the correct result. The formula uses the actual values in the range B3:B5, not the displayed values.<br />

558

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

Saved successfully!

Ooh no, something went wrong!