You are on page 1of 9

Using Spreadsheets to Solve Problems

1.2 Copying Formulas


As we have seen previously, one of the major advantages of using an electronic spreadsheet application is the ability to write formulas that can reference other cells. Thus, we can make changes to one variable on the spreadsheet and automatically affect all other values that use this variable directly or indirectly. You may have also noticed that frequently we need to use the same formula over and over again, each time with a different set of numbers. For example we may want to total rows 5 through 7 in column B and then create similar totals in columns C and D. In cell B8, one could write the formula =B5+B6+B7, and then in cell C6 write the formula =C5+C6+C7. The only thing that is different in these two formulas is the column being referenced. Clearly with a large spreadsheet, writing this formula out individually for many columns would be a repetitive time consuming task, something we know computers are good at. Wouldnt it be nice if we could tell the computer we want the same formula in C8 as in B8 but just changed to reference cells one column over? Excel allows us to copy formulas in this way. When Excel copies a value such as 5 it can only copy it as another 5 just as a word processor would do with text. When cell references are used, Excel has the ability to change them relative to where the formula is being moved. So =B5+B6+B7 when copied across one column would now be =C5+C6+C7. This difference allows us to use a general formula over and over again, but with respect of a different set of numbers. To do this, we utilize a feature called Absolute and Relative cell addressing. Copying Formulas Relatively
1 2 3 A data: B C D # weekdays per week # weekend days per week E F 4 1 G

4 5 6 7 8

Item Food Lodging Transportation total

Price per Price per Total weekday weekend Weekly % Cost % Cost % Total day day Cost Weekday Weekend Cost 25 50 150 50% 59% 53% 15 35 95 30% 41% 33% 10 40 20% 0% 14% 50 85 285

Figure 1 Let us look at the spreadsheet in Figure 1 that summarizes our companys travel costs per week. As we mentioned previously, it would be nice to write a formula to total Food, Lodging and Transportation costs in the price per weekday column and then copy it relatively into the price per weekend day and total weekly cost columns. What we essentially want to do is copy the formula such that the operands change relative to the location where we copy it. So if we place the new formula one column to the right of the old formula we want the operands used in the formula to also change one column to the right. Cell references such as B5, B6 and B7 are referred to as relative cell references. Relative cell references change when they are copied relative to their displacement. We will also learn how to

Copying Formulas 1-2

Page 11

Using Spreadsheets to Solve Problems reference cells absolutely. Absolute cell references do not change even when copied into different cells. When copying a formula, the computer determines if a specific cell reference is relative. If the reference is relative, the computer will automatically change that reference relative to where the formula is being moved. Cell references are by default relative; therefore no special characters are required. In the example in Figure 1, in cell B8 is the formula = B5+B6+B7. When copying this formula into cell C8 it will be automatically adjusted to reference the corresponding cell in column C. All cell references will change relative to the displacement of the original formula. The displacement from B8 to C8 is one column and zero rows. Therefore one column and zero rows will be added to each relative cell reference in the formula. The resulting formula in cell C8 will be =C5+C6+C7. Constants in formulas (numerical values) remain unchanged in this process. An example: What formula would result if you copied the formula =B2 + C2/ D4 from cell E8 to cell E12? The displacement from E8 to cell E12 is 0 columns and 4 rows. This would be applied to each relative cell reference in the formula. In the first operand B2, column B plus 0 columns would remain column B, and row 2 plus 4 rows would become row 6 resulting in the new cell reference B6. Similarly the second operands C2 becomes C6 Adding 4 rows to the operand D4 results in the cell address D8. The resulting formula in cell F12 would be =B6 + C6/D8.

Another example: What formula would result if you copied the formula =B6 C7 + 2 from cell D9 into cell F12? The displacement from D9 to F12 is 2 columns and 3 rows. This would be applied to each relative cell reference in the formula. In the first operand B6, column B plus 2 columns would become column D and row 6 plus 3 rows would become row 9 resulting in the new cell reference D9. Similarly the second operand C7 would be adjusted to become E10. The resulting formula in cell F12 would be =D9E10+2.

To copy a formula you can use the copy/paste features from the toolbar or the Edit menu. Another method of copying a formula into an adjacent cell or cells is to use the Fill Handle. When you move the mouse pointer to the lower right hand corner of the cell it turns the pointer into a plus sign, which is the fill handle. Once the + sign appears just drag it into the desired cell or cells. The formulas should be automatically copied. Copying Formulas Absolutely. Again let us look at this travel spreadsheet in Figure 1. In cell D5 is a formula to calculate total weekly costs of food. To calculate the weekly costs we take the price per weekday for food times

Copying Formulas 1-2

Page 12

Using Spreadsheets to Solve Problems the number of weekdays plus the price per weekend day for food times the number of weekend days. In Excel syntax that would be =B5*F1+C5*F2. Now we want to copy the formula in cell D5 and copy it into cell D6 to determine the weekly costs for lodging. If we use relative cell addressing and displace the formula 1 row, 0 columns the resulting formula is =B6*F2+C6*F3. Does this give us the correct formula? It does not. The new formula multiplies the lodging costs for weekdays by the number of weekend days. We really wanted to change the food costs relatively but we wanted to keep the # of weekday days and # of weekend days the same. We can accomplish this by using absolute cell referencing for these terms. An absolute cell reference is one that does not change regardless of where it is copied. No matter how you displace a formula, absolute cell references will remain unchanged. To indicate that a cell reference is absolute, we use dollar signs ($) in front of both the column and row of the cell address. Thus, if we wrote the original formula in cell D5 as =B5*$F$1+C5*$F$2 we could correctly copy it into the rows below to calculate weekly costs of Lodging and Transportation. Mixed Cell Referencing There are also times, when copying formulas, where we wish to copy a cell reference relatively to its column and absolutely to its row or visa versa relatively to its row and absolutely to its column. This becomes especially evident when copying a formula both down and across at the same time.
A data: B C D # weekdays per week # weekend days per week E F 4 1 G

1 2 3

4 5 6 7 8

Item Food Lodging Travel total

Price per Price per Total weekday weekend Weekly % Cost % Cost % Total day day Cost Weekday Weekend Cost 25 50 150 50% 59% 53% 15 35 95 30% 41% 33% 10 40 20% 0% 14% 50 85 285

Figure 2 Refer to the Travel expense worksheet as seen in Figure 2. In cell E5 to G7 we want to calculate the component cost as a percentage of the total cost for that category i.e.: In cell E5 would have the food costs for weekdays as a percentage of total weekday expenses, and cell G7 would have total travel costs as a percentage of overall total costs. We want to be able to write one formula in cell E5 and copy it both down and across to get the desired result. The mathematical formula to calculate the value in cell E5 would be as follows: food costs for weekdays divided by total costs for weekday. In Excel syntax it would be =B5/B8. Now consider copying this formula down the column and across the row. When we copy this formula down the column in cells E6 and E7, we want the operand B5 to change relatively and B8 to remain the same. Specifically, in the operand B8, we want the
Copying Formulas 1-2 Page 13

Using Spreadsheets to Solve Problems row to remain unchanged. If we change the denominator to an absolute cell reference =B5/$B$8 what happens when we copy it across to calculate the weekend percentages? When copying across, again we want B5 to change relatively. But what about cell reference B8? Do we still want to divide the costs by the weekday total? No, we want to divide these costs by the weekend total. Hence, we want the row of the denominator to stay the same when we copy the formula down the column but we want the column to change when we copy the formula across the row. We indicate this by writing the formula as =B5/B$8. The meaning of cell reference B$8 means relative column B and absolute row 8. The software would then apply the displacement to only the relative parts of each reference.

For practice lets look at a few examples of how formulas change when they are copied: What formula would result if you copied =B5+B$5+$B5+$B$5 from cell D1 into cell E3? Note that references B5, B$5, $B5, $B$5 all represent the same cell which in this case contains the value 25. The difference between these references is in how they will be copied. First determine the displacement, the number of rows and columns the formula is being moved. In this case the displacement from column D to column E is one column, and the displacement from row 1 to row 3 is two rows. Apply the displacement of 1 column and 2 rows to each part of each cell reference. B5 is a relative reference, so column B will become column C and row 5 will become row 7. The new reference is C7. B$5 is relative with respect to column and absolute with respect to row. So column B will become C and row $5 will remain the same. The new reference C$5. $B5 is absolute with respect to column and relative with respect to row. So $B will remain the same and 5 will become 7. The new reference will be $B7. $B$5 is absolute with respect to both column and row, therefore there will not change at all when the formula is displaced.

The resulting formula would be =C7+C$5+$B7+$B$5.

Copying Formulas 1-2

Page 14

Using Spreadsheets to Solve Problems What formula would result if you copied =B2+1 from cell C2 into cell B1? What formula would result if you copied =B2+1 from cell C2 into cell A1? Thus far we have been displacing our formulas to the right and down only. Can we copy into formulas to rows above and columns to the left of our original formula? This is perfectly legal to do in Excel. In this example we are displacing the formula 1 row and 1 column. The resulting formula would be =A1+1. But what happens if we try to displace this same formula from cell C2 into cell A1? How can we displace B2 minus 2 columns? There is no such column. Thus, the computer will create the following formula = #REF!+1. In the cell the value displayed will be #REF!. This error message indicates to us that you have made an illegal cell reference. Named Ranges Another tool, that Excel provides with their spreadsheet, is the ability to name a cell or range of cells and later use these names in formulas and functions. When you identify a cell or cells with a name this is referred to as a Named Range. There are two methods to naming a range: Use the menu item Insert and then choose Name Highlight the cell or cell(s) and type in a name in the Name Box which appears in the upper left hand part of the window just to the left of the Formula Bar (Refer to Figure 1 Chapter 1.1).

Named ranges work differently than actual cell references. When used in formulas, named ranges copy absolutely. So if a value is constant and required in many formulas, it might be easier to give it a name and just use that name directly in your formulas. Recall the spreadsheet we used previously, as seen in Figure 3.
A data: B C D # weekdays per week # weekend days per week E F 4 1 G

1 2 3

4 5 6 7 8

Item Food Lodging Travel total

Price per Price per Total weekday weekend Weekly % Cost % Cost % Total day day Cost Weekday Weekend Cost 25 50 150 50% 59% 53% 15 35 95 30% 41% 33% 10 40 20% 0% 14% 50 85 285

Figure 3 If we were to name cell F1 weekdays and cell F2 weekends then we could write the formula for total cost in cell D5 as follows: = B5*weekdays+C5*weekends. When this formula is copied down the column both weekdays and weekends do not change. However, no absolute cell referencing is required since this is already taken care of by using a cell name. In a similar fashion we could name the range B5:B7 ppwd. We will see in the next chapter how this can be

Copying Formulas 1-2

Page 15

Using Spreadsheets to Solve Problems used when writing functions. Named ranges are best used with constants that dont change or ranges that we reuse in our formulas. Error Messages We introduced the error message #REF! in a previous section. It is important that you also be aware of several other common error messages, so that you can quickly and easily debug your spreadsheets. These messages are specific to the Excel application. Different spreadsheet applications may use different error message symbols. ##### #DIV/0! #N/A #NAME? #NUM! #REF! #VALUE ! Numeric value too wide to display Divide by 0 occurs Data being referenced is not available Text in formula is not recognized Problem with a number in a formula or function Cell reference is not valid Wrong type of argument or operand in a formula

Copying Formulas 1-2

Page 16

Using Spreadsheets to Solve Problems

Exercise 1.2 1 Writing Formulas & Using Relative/Absolute Cell


Referencing 1. What new formula would result for each of these cases below if the formula was copied from cell B3 to cell D6? (a) = A1+A2 (c) = $A1+A2 (d) = A$1+A2 ____________________________ ____________________________ ____________________________ (b) = $A$1+A2 ____________________________

2. What formula would result if you copied the formula =A1+A2 from cell E7 to cell D9? 3. What value would result in cell B2 if you copied the formula = A1+A2 from cell B3 into cell B2. Base questions 4-7 on the spreadsheet below:
1 2 3 4 5 A Name John Mike Allison B Age C D # Candles % Total 12 13 45% 6 7 24% 8 9 31% 29
A 1 2 3 2 4 6 B

total:

4. What Excel formula can be written in cell C2, which can be copied down the column (C3:C4) to determine the number of candles needed for this childs birthday cake. You will light one candle per year plus an extra one for good luck. 5. What Excel formula can be written in cell C5 to determine the total number of candles you will need? 6. If you insert a row between Mike and Allison and added another child named Fred who is age 4, how would that affect the value you calculated in question 5? 7. Write an Excel formula in cell D2, which can be copied down the column to determine the number of candles being lit for this child as a percent of the total candles being used.

Copying Formulas 1-2

Page 17

Using Spreadsheets to Solve Problems

Exercise 1.2 2 Creating a Multiplication Table

A 1 2 Values: 3 1 4 2 5 3 6 4 7 5 8 6 9 7 10 8 11 9 12 10

B 1 1 2 3 4 5 6 7 8 9 10

C D E F G H Multiplication Table 1 through 10 2 3 4 5 6 7 2 3 4 5 6 7 4 6 8 10 12 14 6 9 12 15 18 21 8 12 16 20 24 28 10 15 20 25 30 35 12 18 24 30 36 42 14 21 28 35 42 49 16 24 32 40 48 56 18 27 36 45 54 63 20 30 40 50 60 70

I 8 8 16 24 32 40 48 56 64 72 80

9 10 9 10 18 20 27 30 36 40 45 50 54 60 63 70 72 80 81 90 90 100

The above spreadsheet can be created using just Three formulas and copying them as required. Assume you have begun to create the spreadsheet above by typing in the labels and values in only the highlighted cells. 1. Write an Excel formula in Cell A4, which can be copied down the column into cells A5 through A12, to create a list that increases by one in each successive cell. 2. In cell C2 write an Excel formula, which can be copied across the column into cells D2 through K2, to create a list that increases by one in each successive cell. 3. Now create the values of the multiplication table assuming for each cell you are creating is product of the corresponding value in column A for that row by the value in row 2 for that column. Write the formula in cell B3 so that it can be automatically copied to complete the table through cell K12

Copying Formulas 1-2

Page 18

Using Spreadsheets to Solve Problems

Exercise 1.2 3 Chapter Review - Relative & Absolute Addressing


A B 1 Book Orders 2 shipping per book 3 Sales Tax Rate 4 5 book price: 6% 6 OSU 6% 7 Columbus State 6% 8 Miami 5% 9 Broward 0% 10 CCNY C $0.50 D E F G H I J K L M

Excel Access PPoint Total Grand % total % total % total Shipping Total Book Book Book Quantity Total Tax Excel Access PPoint $ 13 $ 15 $ 9 2000 500 2500 5000 $ 56,000 $ 3,360 $ 2,500 $ 61,860 40% 10% 50% 1500 300 1500 3300 $ 37,500 $ 2,250 $ 1,650 $ 41,400 45% 9% 45% 0 0 3000 3000 $ 27,000 $ 1,620 $ 1,500 $ 30,120 0% 0% 100% 175 175 175 525 $ 6,475 $ 324 $ 263 $ 7,061 33% 33% 33% 800 300 1000 2100 $ 23,900 $ $ 1,050 $ 24,950 38% 14% 48%

1. (a) Write an Excel formula in cell G6, which can be copied down the column to determine the total value (excluding tax and shipping) of this order. For example OSU will buy 2000 copies of the Excel book at $13 a copy, 500 Access books at $15 a copy and 2500 PPoint books at $9 a copy. Be sure to use cell references. 1 (b). When you copy the formula you wrote in cell G6 to cell G10, what formula will result? 2. Write a formula in cell H6, which can be copied down the column to determine the sales tax (total * tax rate) for this order. 3. Cell C2 has been named Ship and contains the cost per book of shipping. Write an Excel formula in cell I6, that can be copied down the column to determine the cost of shipping. Use the named range. 4. Write an Excel formula in cell J6, which can be copied down the column, to determine the Grand Total of this order (total cost of books, tax and shipping). 5. (a) Write an Excel formula in cell K6, which can be copied both down the column and across the row to determine the percentage total of this book for this order. Hint: divide the number of this type of book by the total number of books in this specific order. 5. (b) What formula will result when you copy the formula you wrote in cell K6 if you copy it into cell M10?

Copying Formulas 1-2

Page 19

You might also like