Read an Excerpt
Chapter 5: Working with Formulas and Values
In this chapter:
- Creating Spreadsheet Formulas (see page 120)
- Referencing Cells on Other Sheets and Spreadsheets (see page 125)
- Copying and Moving Formulas (see page 128)
- Naming Cells and Ranges (see page 129)
- Working with the Navigator (see page 133)
- Using the Calc Detective (see page 134)
- Using Special Data Entry Techniques (see page 137)
- Working with Data Series and the Fill Feature (see page 138)
Creating Spreadsheet FormulasOne of the most important characteristics of a spreadsheet application like Calc is that it is designed to do math. The whole point behind building a spreadsheet is to have the data that we enter into the spreadsheet acted on by a formula or formulas; we are looking for mathematical results.
As discussed briefly in Chapter 2, you have two options for performing math in a Calc spreadsheet: you can design your own formulas, or you can use the built-in math functions that are provided by Calc.
In this chapter, we will discuss the ins and outs of creating your own formulas and some of the enhancements and features provided by Calc that make it easier to work with formulas, functions, and values. Functions will be covered in the next chapter.
Before we take a look at the issues related to creating your own formulas, be advised that a good rule of thumb is to only create formulas in cases where Calc does not provide a function that will do the same job. You will find that for the most part, you can limit your creation of formulas to simple math such as sub-traction, multiplication, and division.
To Use OperatorsThe formulas that you create will consist of cell references (the address of the cell or cell range that the formula will act on) and operators. The operator, such as the plus sign (+), which is used for addition, will dictate the type of operation (or operations) the formula will actually provide.
When you begin a new formula, you will start the formula's notation with the equals sign (=). This lets Calc know that the data in the cell is actually a formula.
The simplest way to enter the equals sign (=) in a cell is to click the Function tool on the Formula bar.
The rest of the formula will consist of the appropriate operators and cell references, which are discussed in the next section. Table 5.1 provides a list of some of the commonly used arithmetic operators....
...NOTE Make sure the Num Lock is engaged on your keyboard. The easiest way to enter operators into your formulas is from the ten-key pad on your keyboard.
To Understand Operator PrecedenceAn important aspect of creating formulas is understanding operator precedence. In simplest terms, operator precedence means that certain operations in a formula take precedence over (or take place before) other operations in a formula. For example, in the formula =b2+b3*c2, the multiplication of b3*c2 takes precedence, so b3 will be multiplied by c2 and then b2 will be added to that result.
Table 5.2 provides a summary of operator precedence that you should keep in mind as you create your formulas. Calc reads your formulas from left to right, so you should position your operators appropriately.
You can also control operator precedence in your formulas using parentheses. Operations enclosed in parentheses take precedence over operations that are not in parentheses. In the formula =(b2+b3)*c2, the parenthetical calculation takes precedence over the multiplication operator. So, b2 and b3 will first be added and then their sum will be multiplied by c2....
To Reference CellsWhen you create a formula (or function) in your spreadsheet, it will reference cells that contain the data that the formula is supposed to act on (using the operators that you place in the formula). For example, the formula =D7*E7 will multiply the contents of D7 by the contents of E7 as shown in Figure 5.1....
...Figure 5.1 Calc formulas use relative referencing, making it easy to copy a formula from one location to another.
While the formula contains specific references to two cells (D7 and E7), Calc actually sees the cells that the formula acts upon based upon their relative position to the cell that actually holds the formula.
For example, D7 is actually seen as a cell that is two cells to the left of the formula, and E7 is seen as a cell that is one cell to the left of the formula. This type of cell referencing is called relative referencing. The reason that this type of refer-encing is so useful is that the formula shown in cell F7 can be copied down the column that it resides in and the formula will adjust to its new location. It will now reference the cells that it is supposed to act upon according to its new position.
So, if the formula is copied from cell F7 to cell F8 as shown in Figure 5.2, the formula still works. This is because of relative referencing. The formula reacts to its new location and references the appropriate cells (relative to its new position).
In some cases where a particular value only resides in a particular place on the spreadsheet (such as a cell that contains a particular percentage or an interest rate amount that is to be used in a formula no matter where you copy the formula on the sheet), you will have to specify the cell reference in the formula as absolute. Absolute referencing (which is what this type of referencing is called) makes sure that the formula always points to the one and only cell where the data resides. The cell reference remains static even when the formula is moved or copied. We will look at absolute referencing and how it is used in Calc functions in the next chapter....