Название | Excel Formulas and Functions For Dummies |
---|---|
Автор произведения | Bluttman Ken |
Жанр | Зарубежная образовательная литература |
Серия | For Dummies |
Издательство | Зарубежная образовательная литература |
Год выпуска | 0 |
isbn | 9781119076797 |
Gaining the Upper Hand on Formulas
Okay, time to get to the nitty-gritty of what Excel is all about. Sure, you can just enter data and leave it as is, and even generate some pretty charts from it. But getting answers from your data, or creating a summary of your data, or applying what-if tests – all of this takes formulas.
To be specific, a formula in Excel calculates something or returns some result based on data in the worksheet. A formula is placed in cells and must start with an equal sign (=) to tell Excel that it is a formula and not data. Sounds simple, and it is.
Look at some very basic formulas. Table 1-1 shows a few formulas and tells you what they do.
Table 1-1 Basic Formulas
Ready to enter your first formula? Make sure Excel is running and a worksheet is in front of you, and then follow these steps:
1. Click an empty cell.
2. Type = 10 + 10.
3. Press Enter.
That was easy, wasn’t it? You should see the result of the formula – the number 20.
Try another. This time you create a formula that adds the value of two cells:
1. Click any cell.
2. Type any number.
3. Click another cell.
4. Type another number.
5. Click a third cell.
This cell will contain the formula.
6. Type =.
7. Click the first cell.
This is an important point in the creation of the formula. The formula is being written by both your keyboard entry and your clicks of the mouse. The formula should look about half complete, with an equal sign immediately followed by the address of the cell you just clicked. Figure 1-14 shows what this looks like. In the example, the value 15 has been entered into cell B3 and the value 35 into cell B6. The formula was started in cell E3. Cell E3 so far has =B3 in it.
8. Type +.
9. Click the cell that has the second entered value.
In this example, this is cell B6. The formula in cell E3 now looks like this: =B3 + B6. You can see this in Figure 1-15.
10. Press Enter.
This ends the entry of the function. All done! Congratulations!
Figure 1-14: Entering a formula that references cells.
Figure 1-15: Completing the formula.
Figure 1-16 shows how the example ended up. Cell E3 displays the result of the calculation. Also notice that the Formula Bar displays the content of cell E3, which really is the formula.
Figure 1-16: A finished formula.
References abound in Excel formulas. You can reference cells. You can reference ranges. You can reference cells and ranges on other worksheets. You can reference cells and ranges in other workbooks. Formulas and functions are at their most useful when you’re using references, so you need to understand them.
And if that isn’t enough to stir the pot, you can use three types of cell references: relative, absolute, and mixed. Okay, one step at a time here. Try a formula that uses a range.
Formulas that use ranges often have a function in the formula, so use the SUM function here:
1. Enter some numbers in many cells going down one column.
2. Click another cell where you want the result to appear.
3. Type =SUM( to start the function.
4. Click the first cell that has an entered value, hold the left mouse button down, and drag the mouse pointer over all the cells that have values.
5. Release the mouse button.
The range address appears where the formula and function are being entered.
6. Type ).
7. Press Enter.
8. Give yourself a pat on the back.
Excel is dynamic when it comes to cell addresses. If you have a cell with a formula that references a different cell’s address, and you copy the formula from the first cell to another cell, the address of the reference inside the formula changes. Excel updates the reference inside the formula to match the number of rows and/or columns that separate the original cell (where the formula is being copied from) from the new cell (where the formula is being copied to). This may be confusing, so try an example so you can see this for yourself:
1. In cell B2, type 100.
2. In cell C2, type =B2 * 2.
3. Press Enter.
Cell C2 now returns the value 200.
4. If C2 is not the active cell, click it once.
5. Press Ctrl + C, or click the Copy button in the Clipboard category on the Home Ribbon.
6. Click cell C3.
7. Press Ctrl + V, or click the Paste button in the Clipboard category on the Home Ribbon.
8. If you see a strange moving line around cell C2, press the Esc key.
Cell C3 should be the active cell, but if it is not, just click it once. Look at the Formula Bar. The contents of cell C3 are =B3 * 2, and not the =B2 * 2 that you copied.
What happened? Excel, in its wisdom, assumed that if a formula in cell C2 references the cell B2 – one cell to the left – the same formula put into cell C3 is supposed to reference cell B3 – also one cell to the left.
When you’re copying formulas in Excel, relative addressing is usually what you want. That’s why it is the default behavior. Sometimes you do not want relative addressing, but absolute addressing. This