Wednesday, May 23, 2007

Excel Formulas are Algebra, part 4

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

One soon runs out of uses for formulas of the type =D8+23.3. While solving algebra problems with lots of variables is tedious (and fraught with errors), this is where Excel shines. Formulas can be quite complex. This simple example just cracks the door open:

Data exist in columns A, B, C, and D, and we want column E to contain the sum of an A times a B, plus a C times a D. Of course (!) there are column labels in row 1, so in cell E2 you can put the formula

=A2*B2+C2*D2

If you are paranoid about the order things are done (multiplies get done before adds, but in larger formulas it gets less clear), you could write that formula as

=(A2*B2)+(C2*D2)

Now, suppose you want the sum of the four items, rather than this mixed sum/product formula, just A+B+C+D. This brings up the subject of Functions. These are named operations that Excel can do, and many work on Ranges. Instead of

=A2+B2+C2+D2

you could have

=SUM(A2:D2)

A2:D2 is the Range name for those four cells. Many formulas take 2-dimensional ranges, so the sum of quite a large area of the worksheet may look like this:

=SUM(A2:Z41)

That's the sum of 1,040 items.

Excel has hundreds of formulas, and the Help can provide lists and explanations. Just one more is worth mentioning, because it is used a lot:

=SQRT(D8)

This will find the square root of any numeric value in cell D8.

No comments: