Thursday, January 17, 2008

How to sum cells by Using labels in Microsoft Excel 2003?

Microsoft Excel is a fantastic tool but one of its downfalls is the use of cell addresses especially when you are trying to sum a series of numbers; however Microsoft has a really cool tool that allows you to add up a series of cells simply using the labels around your data. In this article we will investigate the steps you need to follow to be able to use Labels to Sum cells in Microsoft Excel.

Let us get started …

To show you how using labels works, the first step we need to undertake is to simply create a new set of data, so open a new Microsoft Excel workbook and click on Sheet 1. First off we are going to build the worksheet so in cell A1 I want you to type - Years, in cell B1 type the word Values and in cell C1 type the word Values1 and in cell D1 type the word Total. These four values we have typed into cell A1, B1, C1, D1 are labels. We are now going to put into the worksheet three more labels. In cell A2 type the value 1999, in cell A3 type the value 2000 and in cell A4 type the value 2001. The last three values entered will in fact become labels but we will convert them to labels a little latter on.

In the remaining cells simply put the following values:

B2 29 C2 32
B3 54 C3 99
B4 62 C4 72

Now that we have built a very simple spreadsheet and we have a few values to work with we have to tell Microsoft Excel to actually accept labels in our formulas in our spreadsheet. We do this by first going to the Tools menu and then choosing the Options command from the drop down menu. The Options dialog box will now be open in front of you. Simply choose the Calculation tab and in the bottom right hand corner you will see a check box that says Accept Labels in Formulas and you need to click on the check box so that it has a tick in it. Then to complete the process simply press the OK button.

Now we can use the labels we put in B1 and C1 to add up the values.

Lets try it out…

In cell B5, which is the Values column I want you to type the formula -

= Sum(Values)

The cell should return the total of 145. What you will notice though is that the formula looked up the column to where the label was and said everything in this column will be added together. We could have simply typed the following formula instead of using labels -

= Sum(B2:B3)

However, as I am sure you will agree, using labels makes your formulas a lot easier to read and much clearer to understand. Now it is your turn. In the cell C5 write the equivalent label formula for that cell. I will give you a hint if you are not sure -

= Sum(Values1)

How did that go?

Alright, the next issue we are going to visit is using numbers as formula labels. Now if we simply typed in cell D2 the formula -

= Sum(1999)

All that would be returned is the value 1999 so this will not work at all. In fact what we need to do is to tell Microsoft Excel that we want the cells in A2, A3 and A4 to be treated as labels. The first step we must do is to select cells A2,A3 and A4, then go to the Insert menu, choose Name from the drop down menu and then choose the Label command from the expanded menu. The Label Ranges dialog box will now be visible in front of you. All you simply have to do, to have the cells we chose before defined as Labels is to press the Add button and then press the OK button.

Click once on the cell D2. What we are going to do now is to type in the same formula I mentioned before and that is -

= Sum(1999)

By the way, press the Enter key if you have not done so already. As soon as you do that you should see that it adds up the values in cells B2 and C2 and you will see the value of 61 in your cell.

Try creating the formulas for the other two cells -

D3 = Sum(2000)

D4 = Sum(2001)

Finally, just to finish our spreadsheet off , we can total all of our total values in cells D2, D3 and D4 by typing the following formula in D4 -

= Sum(Total)

Using labels in Microsoft Excel is a very clean way of summing your values as it ensures that you do not miss a cell address and it makes the formulas a lot simpler. One issue that I do teach my students is not to put blank rows in your spreadsheets as I have seen cases where the blank rows actually affected the ability of the application to work out what was a label and what is not. By following the design process I outlined above you will find that you have absolutely no troubles in using Labels to sum cells in your spreadsheets.

No comments: