November 11, 2008

Way Back to School: Simple Addition Excel Style

Welcome back to grade school. Unfortunately, you will receive no virtual gold star stickers for good performance, but on the bright side, you will not have to sit in timeout or miss recess if you don't do your homework. You are old enough and motivated enough to do your homework for the sake of self-betterment, right? RIGHT?

Before getting too far along, let's download the "Addition" worksheet here.

With that we move on to adding numbers together. Excel provides two basic ways of adding number together: the operator '+', and the function SUM. I'm assuming that you, the reader, know how to add two numbers together (if not, no recess for you), thus I am going to focus on how to transfer your knowledge to the spreadsheet.

Operators:
Using an operator is the most intuitive way to perform arithmetic functions. You basically write it as you see it:

Excel: = 2 + 5
Your Brain's version: "what is 2 plus 5?"

Okay, so maybe it's a bit different. The '=' sign always goes in the front (even though the formula in your head is "2 plus 5 equals 7"), I cannot stress this point enough. Without the '=', Excel assumes you are just writing "2 + 5" for the fun of it. And trust me, you are not writing "2 + 5" for the fun of it. This form is intuitive because it's almost exactly as you would type it into a simple calculator (which they didn't tell you about until middle school). Again, with the difference that the '=' goes at the beginning, rather than the end.

Functions:
Okay, this is not quite as intuitive a translation, but is more along the lines of how you do things in Excel's language. Let's try the same example:

Excel: =SUM(2,5)
Your brain's version: What is the sum of the following numbers: 2 and 5?

This version is more efficient than the previous translation when dealing with a Series of numbers. A Series is a list of numbers or references, separated by commas. The SUM function can take a Series as its Argument. An Argument is the information you feed into a function, that allows it to come up with a solution. You can also call Arguments "Parameters", which is probably more accurate, but also more scary, so I will stick with the word Argument. For example, if you just wrote SUM(), Excel would answer with a blank stare, because it does not know the numbers you want to sum up. However, if you type =SUM(2,5), Excel knows that you want to add 2 and 5 together, and smiles at you. The SUM function takes a variable number of Arguments, depending on how many numbers you want to add together. Most of the Arithmetic functions work this way, but most of the more complicated functions take a fixed number of Arguments. This may not make too much sense right now, but don't worry about it, it will become clear over time what exactly we mean by an Argument.

In addition to a Series, SUM can also take a Range as an argument. A Range is a continuous group of references. These are examples of Ranges:

1. A1:A4 (includes cells A1, A2, A3, A4)
2. A1:C3 (includes cells A1, A2, A3, B1, B2, B3, C1, C2, C3)

Notes about Ranges:
1. Always Rectangular: The first reference defines the top left corner of the range, the colon signals that you are creating a range, and the second reference defines the bottom right corner. Excel takes this information and creates the associated rectangle.

2. Can use Absolute or Relative References: For a review of how these references work, check out this post. This is only important if you intend to fill your function or copy and paste it (which I always encourage). $A$1:$A$4 will always refer back to those cells, no matter where you fill or copy and paste the function. This is not true of A1:A4, which is a relative range, and will move around if you start filling or copying and pasting your function.

For example, if you put =SUM(A1:A4) in cell A5, and then fill it down to cell A6, you will get a different answer, because Excel translates your function to =SUM(A2:A5) in A6, which will be larger than =SUM(A1:A4). In contrast =SUM($A$1:$A$4) will always take the sum of those four numbers, no matter where you put it.

You can also use any sort of combination of relative and absolute references mentioned in the aforementioned post.

Back to SUM
The biggest advantage of SUM over '+' is that SUM can take a Range as an Argument. So if you want to add all the numbers in Column A from Row 1 to Row 100, instead of typing each number, which would be spectacularly awful, you can simply do =SUM(A1:A100) and let your buddy Excel do the rest. Don't you wish you knew how to use it in third grade?

In most circumstances, you will want to Sum a Range. I encourage you to do your own scratchwork on the worksheet I provide above, just to get used to doing it. Because that's what you would have had to do in grade school.

No comments: