Recipe1.6.Exploring the R1C1 Cell Reference Style


Recipe 1.6. Exploring the R1C1 Cell Reference Style

Problem

You've seen the use of the A1 style of cell reference in Recipe 1.5 and are wondering if there are other ways to refer to cells.

Solution

Yes, there are other ways to refer cells, such as the R1C1 style.

Discussion

Besides using the A1 style of cell reference, you can also use the so-called R1C1 style of cell reference. This is not the default style, but in some cases it can be more intuitive or conducive to matrix operations and programming, as we'll see later.

The R1C1 style uses numbers to identify both rows and columns in a spreadsheet. For example, R1C1 refers to the cell in row 1 column 1. To use the R1C1 style you must first activate it. To do so, go to the Tools Options... menu to open the Options dialog box. Once its open, press the General tab (see Figure 1-12).

Figure 1-12. General tab in the Options dialog box


Check the box next to R1C1 reference style under the Settings heading to activate the R1C1 style. When you press OK and return to your spreadsheet, you'll see that the column headings have changed from letters to numbers, as shown in Figure 1-13.

Figure 1-13. R1C1 reference style


Also notice that Excel automatically changed the formulas. For example, the formula in cell D7 (now R7C4) was =B7*C7; now it's =RC[-2]*RC[-1], which is a relative reference in R1C1 style.

When using the R1C1 style, if you enter a cell reference like R3C5 (i.e., R followed by a number and C followed by another number), you are using absolute cell references. The equivalent in A1 style would be $E$3. Using brackets around the number following either R or C indicates relative cell references. For example, R[1]C[2] refers to the cell one row down and two rows to the right of the cell containing that reference. The cell two rows up and one row to the left would be referred to as R[-2]C[-1]. An R or C not followed by a number or a number in brackets refers to the same row or column as the cell containing the reference.

See Also

To learn more about cell references, see Recipe 1.7 and Recipe 1.14. You can also check out the Excel Help topic "About cell and range references."


Recipe 1.7. Referring to More Than a Single Cell

Problem

Sometimes you need to refer to a group of cells, not just a single cell. For example, some formulas discussed in Recipe 1.10 take more than a single cell as an argument. Thus you need to know the syntax for referring to more than one cell.

Solution

Use cell ranges .

Discussion

A cell range is simply a contiguous group of cells in rows or columns, or both. For example, the cell reference A1:A10 refers to the range of cells in column A from row 1 to row 10. The colon character (:) is used to indicate a range reference. The reference A1:B10 refers to the range of cells from column A row 1 to column B row 10. Technically speaking, the cell reference A1 is itself a range of only a single cell; thus, in a sense, all cell references can be thought of as ranges.

See Also

See Recipe 1.10 for examples on where ranges are required as function arguments.


Recipe 1.8. Understanding Operator Precedence

Problem

You want to learn the specific order in which Excel executes operations in formulas.

Solution

Excel performs operations in formulas from left to right following the leading equals sign. In doing so, Excel performs specific operations, if they are encountered in your formula, in the following order of precedence: negation, exponentiation, multiplication and division, and addition and subtraction.

Discussion

You can change operator precedence using parentheses. For example, if you enter the formula =A1+B2/C3 in a cell, Excel will perform the division first and then the addition. This may be what you wantthat is, you want to add the result of B2 divided by C3 to A1. However, if you intend to divide the sum of A1 and B2 by C3, then you need to write =(A1+B2)/C3. The parentheses force Excel to perform the addition operation first, followed by the division.

You can also nest parentheses. For example you could write =((A1+B2)/C3)*C4, and so on. I find it is always good practice to use parentheses liberally to be sure your formula is executed as intended.