Tuesday, May 22, 2007

Excel Formulas are Algebra, part 3

If you are already familiar with Excel formulas, you don't need to bother with this post or its companions of similar title.

Introduction to Formula Syntax: Excel formulas are adapted from the BASIC programming language, which has its roots in FORTRAN and COBOL. A formula just describes an operation, or a series of operations. If you decode the word Mathematics, its root is "operate". The symbols used in BASIC statements and in Excel formulas solve the problem of telling the computer what you want to do. So, here are the five fundamental "verbs":

+ means add
- means subtract (you knew these two)
* means multiply (because X and x are letters)
/ means divide (rather than ÷, which is a "special character")
^ means raise to a power (I'll explain shortly)

All other operations you might need, like a square root or some trigonometry, are handled by Functions. Those come later.

Let me first explain powers. They are like multiplication, taken to another level. Just like multiplying is a short way of performing repeated addition (5*3 = 5+5+5 = 15), taking a power is a short way of describing repeated multiplication (5^3 = 5*5*5 = 125). The second and third powers come into daily life so frequently that we have names for them, the square and the cube. Thus, most folks know that areas are measured in square feet, square yards and square meters, while volumes are measured in cubic feet or whatever.

As mentioned in the former post, a simple multiplication formula looks a lot like algebra. So this algebraic formula:

y=x*1.04

might look like this in an Excel cell:

=C4*1.04

Where did "x" and "y" go? "y" is the cell the formula is in and "x" is the column/row name of a cell you're telling Excel to operate on. Every cell in a workbook has a name, which is the column and row in which it is located. JB47650 is a cell very far from the "home cell" A1. The last column is IV, the 256th column, and the last row is 65536 (multiply these numbers, and you'll see that an Excel worksheet can contain 16,777,216 cells...for now).


Therefore =C4*1.04 tells Excel "Get a number from cell C4 and multiply it by 1.04; show the result in place of this formula." When you look at the worksheet, you just see the result. To see the formula, click on (select) the cell. Its literal contents are shown in the Formula Window near the top of the screen.

No comments: