Spreadsheets 2: Calculate! Name: Main: Spreadsheets are convenient for organizing text information in charts and rows. However, they can also act like a calculator to perform all sorts of mathematical tasks. This handout will explain how to program cells in your spreadsheet to do several common mathematical jobs, such as finding an average, counting, and rounding. You will also learn how to use Fill Special to quickly enter commonly used information such as the days of the week, a series of numbers, dates, etc. Finally, you will learn how to sort the data in columns. When you have finished this handout, you should have the following skills: Creating "titles" for cells Using COUNTIF Using AVERAGE Using ROUND Creating average formula by hand Sorting data in multiple columns Entering Information using AutoFill Open a new spreadsheet document in Excel. Go to View-->Header and Footer to create a header with your name, date and section on the right. Type the title Calculate! in the center. Save the file as calc(yi).xls in your network spreadsheet folder. Click on cell B1 and type Month. This will be the title for column B. (You are skipping column A for now.) Click on cell C1 and type No. of Days. This will be the title for column C. Click on cell B3 and type January. Notice that you are skipping row 2 to make things easier to read. Click on the lower left corner of cell B3 and drag. You should see the month names start to show as Excel will automatically recognize that you are beginning a series of months. Keep dragging down to cell B14 and let go of the mouse button. The months from January to December should now show in column B Page 1
Next, enter the number of days for each month starting in cell C3. (Youʼll have to type this information by hand!) You can assume that February will have 28 days. Your spreadsheet should look like this now: Save your work. Using Functions and Formulas Now you will program some of the cells to automatically count the number of months, and to subtotal the number of 31-, 30-, and 28-day months. Click on cell A16 and type 31 days. Click on cell A17 and type 30 days. Click on cell A18 and type 28 days. Click on cell A20 and type Total Months. (Note: You will probably need to make column A wider to fit this in properly.) Click on cell B16 and type the following formula: =COUNTIF(C3:C14,"31"). This tells the computer to check all the cells from C3 to C14 and count how many of them have 31 typed in. Click on cell B17 and use the COUNTIF function to find the number of months with 30 days. Then click on cell B18 and use COUNTIF to find the number of months with 28 days. Page 2
Click on cell B20 and use the SUM function to add up the total number of months in B16, B17 and B18. (Hint: if youʼve forgotten how to use SUM, check the first spreadsheet handout.) When you have finished, your spreadsheet should look like this: This would not have been hard to do by hand instead of using COUNTIF and SUM. It is easy to count 12 months and find the subtotals for 31, 30 and 28 days just by looking at the data. However, if you had a large amount of data, these functions would save you a lot of time. Also, the numbers in cells B18, B19 and B20 will automatically change if the numbers in column C are changed. The number in B16 will change if you erase one of the months in cells B3 to B14. Try it and see! (Then change the data back to the way it looks in the picture.) Page 3
Now you will find the average number of days in a month. Click on cell B22. Type Average. This is just a title; it wonʼt actually calculate anything. Click on cell C22. Then type the following formula: =average(c3..c14) and press Enter. The number in C22 is not rounded. To round it, click in C23 and type the following formula: =round(c22,2). What this formula tells the computer to do is to take the number in C22 and round it to 2 decimal places. Have you noticed a pattern with the functions? They always begin with the equal sign (=) The special function word comes next (average, round, countif, sum) The group of cells being worked on (the cell range) is in the parentheses. Sometimes, extra information is included in the parentheses: =round(c22,2), for example. You can also write a formula from scratch to tell a cell to do addition, multiplication, subtraction, or division without using a special function word. Click on c20. Type =b16+b17+b18 and press Enter. As you can see, you get the same answer (12) that you got in B20. Now for a little challenge: Click on cell C24 and type in a formula so that it shows the average number of days in a month, but this time, do not use the average function. (Hint: you will need to know that the forward slash, /, is the division sign. Also, remember the sum function from the Magic Square handout can be used to add a group of numbers in a column or a row.) When you have successfully programmed cell C24, click on C25 and use the round function to round your answer to one decimal place. IMPORTANT: Save your spreadsheet before going on. If you make a mistake in the next section that you canʼt undo, close the file without saving changes and then open it again. Page 4
Sorting Data in a Spreadsheet When you sort data in a spreadsheet, it isnʼt hard but you do need to pay careful attention to what you are doing. The most important thing to keep in mind is that you must select all of the cells you want to sort, not just the cells in one column. On the other hand, do not select cells that you donʼt want sorted or your data will get all jumbled up. Letʼs sort the data in the spreadsheet alphabetically by month: Highlight cells B3 through C14. Go to the Data menu and select Sort. Look at the Sort window that opens up. There are three separate lines where you set which column to sort by. Since we want to sort by Month, and since the months are in Column B, we will leave the Sort by window set to Column B. Notice you can sort Ascending (A-Z) or Descending (Z- A). Leave it set to Ascending now. Press OK. Your spreadsheet should look like this. If it does, Save. (If not, go to Edit-->Undo Sort and try again.) Page 5
Now practice using Sort using the next several steps: Sort the data so that it is organized by number of days from most to least. If you do it right, your spreadsheet should look like this: Save your work. Now sort your data so that it is in order from smallest number of days to largest number of days AND so that it is still in alphabetical order (A-Z) within the group of months with 30 days and the group of months with 31 days. HINT: You have to use TWO of the lines in the Sort window and youʼll have to decide which column to use first and which to use next. If you do this correctly, your data should look like this: Save your work. Print out calc and turn it in. Page 6
Applying What Youʼve Learned Now you will create a new spreadsheet from scratch to make sure you really understand the skills covered in this handout. As you work, use the previous pages as a model for this new spreadsheet. Open a new spreadsheet in Excel and save it in your network spreadsheet folder as calc2(yi).xls. Create a header with your name, date and section properly right aligned. The title of this spreadsheet will be Class Information. In one column of the spreadsheet, enter the first name of each student in the class. Donʼt forget to give your column a title: Name In another column of the spreadsheet, enter f next to each female studentʼs name and m next to each male studentʼs name. Donʼt forget to title this column Gender. Use COUNTIF to find the number of female students and the number of male students. Donʼt forget to title your cells # Females and # Males. (See page 2 if youʼve forgotten how to use this formula.) Sort your data so that all the boysʼ names come first and then all the girlsʼ names. Then sort it again so that it stays sorted by boys and girls but also the boysʼ names are in alphabetical order and the girlsʼ names are in alphabetical order. (You choose whether it is A-Z or Z-A!) Add a third column for the number of pets belonging to each student in the class. Donʼt forget to title this column Number of Pets Enter each studentʼs number of pets by using the data collected in class. Use average to find the average number of pets for the whole class. Donʼt forget to make a cell with the title Number of Pets. Round the average number of pets to 2 decimal places. Sort your spreadsheet so that it is sorted into boys and girls with the boys from most to least number of pets and the girls from least to most number of pets. For example: Boys are most to least Girls are least to most Save calc2, print it out and turn it in. Page 7