Intermediate Excel By: Jim Waddell Ph: 5-3118 wadde001@tc.umn.edu Last modified: September 2005 Topics to be covered: Notes: What Are Functions? .......................................................................................................... 3 Typing Functions ................................................................................................................ 4 Using AutoSum ................................................................................................................... 5 Other Common Functions ............................................................................................... 6 Using the Function Wizard ................................................................................................. 6 Absolute and Relative References ...................................................................................... 8 Using the IF Function ......................................................................................................... 8 Lookup Functions ............................................................................................................... 9 Statistical Functions .......................................................................................................... 11 An “Array” Function..................................................................................................... 11 List Boxes (and other ways to pick a number) ................................................................. 12 List Box ......................................................................................................................... 12 Combo Box ................................................................................................................... 12 Scroll Bar ...................................................................................................................... 12 Spinner .......................................................................................................................... 12 Financial Functions ........................................................................................................... 13 Exercises: Exercise 1 ............................................................................................................................ 1 Using the IF function ...................................................................................................... 1 Exercise 2 ............................................................................................................................ 2 Using the VLOOKUP function ...................................................................................... 2 Exercise 3 ............................................................................................................................ 4 Some Statistical Functions. ............................................................................................. 4 Exercise 4 ............................................................................................................................ 6 An Array Function .......................................................................................................... 6 Exercise 5 ............................................................................................................................ 7 How to change the value of a cell ................................................................................... 7 The List box. ................................................................................................................... 7 Combo Box ..................................................................................................................... 8 Scroll Bar ........................................................................................................................ 8 Spinner ............................................................................................................................ 9 Which control to use? ..................................................................................................... 9 Exercise 6 .......................................................................................................................... 10 Calculating loan payments ............................................................................................ 10 Intermediate Excel – Page 2 What Are Functions? Functions are complex ready-made formulas that perform a series of operations on a specified range of values. For example, to determine the sum of a series of numbers in cells A1 through H1, you could create a formula using the information from the previous chapter: =A1+B1+C1+D1+E1+F1+G1+H1 A faster and easier way would be to use the SUM function, which is a command built into Excel to add a range of numbers: =SUM(A1:H1) Every function consists of the following three elements: The = sign indicates that what follows is a function (formula). The function name, such as SUM, indicates which operation will be performed. The argument, such as (A1:H1), indicates the cell addresses of the values on which the function will act. The argument is often a range of cells, but it can be much more complex. You can enter functions by typing them in cells or by using the Function Wizard. Some of Excel’s most common functions are listed in the table on the next page. Function AVERAGE Example =AVERAGE (B4:B9) MIN MAX SUM =MIN(B4:B10) =MAX(B4:B10) =SUM(A1:A10) Description Calculates the mean or average of a group of numbers. Returns the minimum value in a range of cells. Returns the maximum value in a range of cells. Calculates the total in a range of cells. Whenever possible, use functions rather than writing your own formulas. Functions are fast, take up less space in the formula bar, and reduce the chance for typing mistakes. Intermediate Excel – Page 3 Figure 1. Functions simplify long formulas and allow you to perform complex calculations. Typing Functions You can type any function into the formula bar or cell just as you would type in a formula. If you remember the function and its arguments, typing may be the fastest method. To type a function, follow these steps: 1. 2. 3. 4. Select the cell where the answer should appear. Type an equals sign (=). Type the name of the function. Type the function’s arguments surrounded by parentheses. (Excel will often fill in the closing parenthesis for you.) 5. Click the Enter button on the formula bar or hit Enter. The answer to the function will appear. Intermediate Excel – Page 4 Using AutoSum Because SUM is one of the most commonly used functions, Excel provides a fast way to enter it – you simply click the AutoSum button in the Standard toolbar. Based on the currently selected cell, AutoSum guesses which cells you want summed. If AutoSum selects an incorrect range of cells, you can edit the selection. To use AutoSum, follow these steps: 1. Select the cell in which you want the sum inserted. 2. Click the AutoSum button in the Standard toolbar. AutoSum inserts =SUM and the range address of the cells to the left of or above the selected cell. 3. If the range Excel selected is incorrect, drag over the range you want to use, or click in the Formula bar to edit the formula. 4. Click the Enter button in the Formula bar or press Enter. Excel calculates the total for the selected range. Figure 2. Using AutoSum. You can quickly sum several columns at once by selecting the cells where the sum should appear and clicking the AutoSum button. Do it! Beginning in cell D4, and going down, enter the numbers 1,2,3, etc. to 10. (Hint: enter the first 2 numbers, drag over both cells to select, then drag the “fill” handle down until the numbers up to 10 are entered) Click cell D14 (just under the last number) and click the “Autosum” button on the toolbar. (It is the capital Greek letter Sigma.) Now hit the enter key and see the sum. Intermediate Excel – Page 5 Other Common Functions If you click in the “Down arrow” next to the Autosum button, you can choose from these commonly used functions: Sum, Average, Count, Max and Min. The “More functions…” choice activates the function wizard, explained below. Using the Function Wizard If you don’t remember a function’s name or arguments, you may find it easiest to use the Function Wizard. The Function Wizard leads you through the process of inserting a function. The following steps walk you through using the Function Wizard: 1. Select the cell in which you want to insert the function. 2. Click the “Down arrow” next to the Autosum button and choose “More functions…” 3. (In old versions of Excel prior to 2000 click the “Paste Function” button on the toolbar, it has an “fx” icon and is located next to the “Autosum” button). 4. Enter the arguments for the formula. If you want to select a range of cells as an argument, click the Collapse Dialog button (or drag the dialog box out of the way). 5. After selecting a range, click the Expand Dialog button if necessary to return to the Formula Palette. 6. Click OK. Excel inserts the function and argument in the selected cell and displays the result. Intermediate Excel – Page 6 Do it! Copy the string of numbers in cells D4-D13 to column E. (Hint: drag over the cells to be copied and then drag the “handle” one column to the right.) Click in cell E14. Click the “Paste Function” button on the toolbar (it is next to “Autosum”) Choose the Statistical Function Category (left pane) and then the “AVERAGE” function (right pane). Excel guesses what to calculate the average of – but we’ll pick the numbers our self. Click on the red and white grid on the right of the “Number 1” line. Now drag over the column of numbers in column E. Exit the cell selection mode by clicking on the red and white box on the right of the line that contains our selection. Click “OK” to finish pasting the function. Is the average correct? Intermediate Excel – Page 7 Absolute and Relative References (Recap!) When you create a formula or function in Excel, you almost always use a relative reference. A relative reference changes depending on where you copy it. In almost all cases, this is exactly what you want. For instance, let’s say you create the formula =SUM(B2:B9) to add numbers in column B. When you copy the formula to column C, the relative references automatically adjust. The formula changes to =SUM(C2:C9). In some cases, a value in a formula must remain constant when copied to other locations. This is referred to as an absolute reference. To identify a cell as an absolute value, a dollar sign ($) must precede the column and row references for that cell. When the formula is copied, the absolute references remain constant in every formula. For example =B1 is a relative reference, while =$B$1 is absolute. In the formula =$B1 the column reference is absolute while the row reference is relative. (What will this formula become if it is copied down one row? … across one column?) Using the IF Function The IF function works by testing a condition you specify (usually related to a cell’s contents), returning one value if the condition is true and another if the condition is false. You can use the IF function to return text, a cell, a number, or a calculation as its “answer.” As usual, Excel dictates that you use the following structure with the function: =IF(Logical_Test, Answer_If_True_, Answer_If_False) You use logical tests every day. When you approach a stoplight, you must look at the stoplight to see if it is green. If the stoplight is green, you go. If the stoplight is not green, you stop. Excel can make logical evaluations for you as long as you use the proper structure. Intermediate Excel – Page 8 The example shown here uses the "IF" function to assign grades. In this situation, the class is graded on a pass/fail basis. Look at the formulae in column "C". The logical test, compares the value in column "B" to a passing score. If the logical test is true, the value "P" is displayed in the cell. If the logical test is false, "F" is displayed. (Text values must be surrounded by quote marks, otherwise Excel thinks it is part of a cell reference and complains!) Do exercise 1 now! Lookup Functions The lookup functions (VLOOKUP and HLOOKUP) select a value from a table and enter it into a location on the worksheet. For example, the VLOOKUP function may be used to look up taxes on a tax table to create a payroll or to look up postage rates to complete a bill of sale. There are two ways to look up data, depending on the way the data is arranged: vertically or horizontally. VLOOKUP (which stands for vertical lookup) looks up data in a particular column in the table, while HLOOKUP (horizontal lookup) looks up data in a particular row in the table. The VLOOKUP function uses the following format and contains three arguments (parts): =VLOOKUP(item, table_range, column_position) ITEM is text, a value, or a cell reference of the item you are looking for (search item) and should be in the first column of the VLOOKUP table. Numerical search items should be listed in ascending order. TABLE_RANGE is the range reference or range name of the lookup table in which the search is to be made. If the lookup function is to be copied, the range should be expressed as an absolute reference. Intermediate Excel – Page 9 COLUMN_POSITION is the column number in the table from which the matching value should be returned. The far left column has a position number of one; the second column has a position number of two, etc. NOTE: Column positions are counted from the left column in the range, not from the left column of the worksheet. The example shown here shows part of a spreadsheet set up to assign grades for a course that is graded A-F. Look at the functions in column "C". The first item (B3) is the score which is going to be looked up in a table. The range "F2:G6" (in absolute reference form) is the table containing scores and letter grades. The final item (2) tells Excel to look in column 2 of the table to find the value to place in the cell. Do exercise 2 now! Intermediate Excel – Page 10 Statistical Functions Excel has a wealth of statistical functions available, many of which you may have to be a statistician to understand. Also, just because the spreadsheet and computer can calculate a sophisticated value, it does not mean that is accurate. While you can probably trust the simpler functions, like AVERAGE, others may not be completely reliable. While checking on some if the more advanced statistical functions, we found that some calculated values differed from examples in a statistical text book! You have been warned. For this workshop, we will calculate a couple of statistical values: average, and standard deviation. Since statistical functions are entered exactly like all of the other functions, the best way to learn is by doing. Do exercise 3 now. Do exercise 3 now! An “Array” Function Most functions return a single value to a single cell. However, there are functions which return a number of values to a range of cells. An example of this is the “Frequency” function which can determine the frequency distribution of a range of values. The most obvious difference between these “Array” functions and the normal type is that you must select a range of cells to receive the results. Another less obvious and non-intuitive difference is in the final step of the Paste Function Wizard. Rather than simply clicking the “OK” button when all of the arguments have been entered you must hold down both the <Control> key and the <Shift> key while clicking OK. We will look at an example of an Array Function in Exercise 4. Do exercise 4 now! Intermediate Excel – Page 11 List Boxes (and other ways to pick a number) Many times in a “what if” scenario, you want to change a number in a specific cell to see how it affects the various calculations. The simple way is to click on that cell and change its value. However, there are several ways to change the value of a cell simply by clicking a button, an arrow or picking from a list. Microsoft’s terminology for these methods of changing the value of a cell are: List Box This is a box inserted into the spreadsheet that displays a list of values. The values are usually contained in a group of cells. When one of the values is selected, the value of the cell to which the box is linked will change according to the value chosen. For example if the list has 3 items, when the first item is selected in the list box, the linked cell will contain the number 1. When the second item in the list box is picked, the linked cell will contain the number 2. And so on. This will become clear when you do the exercise. The exercise will use all of the ways to change a cell’s value, so read on… Combo Box This is a variant of the list box where only the currently selected value is displayed. The other values in the list are displayed from a drop-down list when the arrow is clicked. Scroll Bar Here a horizontal scroll bar is displayed in the spreadsheet. When scrolled, the value of the linked cell is increased or decreased according to the properties defined for the scroll bar. No values are displayed with a scroll bar. Spinner A spinner is essentially the vertical equivalent of a scroll bar. However, only the up and down arrows are displayed with no bar between them. Do exercise 5 now! Intermediate Excel – Page 12 Financial Functions Excel has a wealth of financial functions, many of which require a banker’s knowledge! However, we will use one of the simpler ones to calculate loan payments. Do exercise 6 now! Intermediate Excel – Page 13 Exercise 1 Using the IF function In a particular test we have decided that a result of .75 or above is a positive, less than that is negative. We will create a spreadsheet that will evaluate numerical scores and tell us whether the test for that sample was positive or negative. 1. Open a new spreadsheet and enter the table shown below. Start in row 4 so that there is room above the table to enter our cutoff value . Sample number Value 1 .77 2 .60 3 .66 4 .80 5 .9 Pos/Neg 2. In cell A1 enter the label “Cutoff value”. 3. In cell B1 enter the value .75. 4. In cell C1 type the word “Positive”. 5. In cell D1 type the word “Negative”. 6. In the “Pos/Neg column for sample 1, activate the “Function Wizard” 7. From the "Function category" logical, choose the IF function. 8. Click on the colored square on the right of the "Logical_test" line and then click on cell containing the value for sample 1. (You may have to move the dialog box out of the way, or collapse it to click on the appropriate cells.) Next type the greater than symbol (>). Now click on cell B1 to complete the formula. (If you collapsed the dialog, expand it again before going to the next step. 9. Click in the Value_IF_true line and then in cell C1 to enter its reference. 10. Click in the Value_IF_false line and then in cell D1 to enter its reference. 11. Before clicking “OK” take a look at the cell references in the dialog box and decide which should be made absolute! (Click on the reference and hit the <F4> key to toggle the correct state.) 12. Now copy the function down the column. Remember how to copy by dragging a "handle"?) 13. Test the spreadsheet by entering different values in cell "B1" and see how the test results change. Intermediate Excel Exercises – Page 1. . Exercise 2 Using the VLOOKUP function 1. Start with a new blank spreadsheet and enter the following data: Sample Data Farm ADG 1 2 3 4 5 6 7 8 9 10 1 0.9 1.5 1.2 1 0.9 1.8 1.7 1.4 1.6 For those unfamiliar with hog farming, this exercise simulates decision making based on the Average Daily Gain (ADG) of the growing hogs on the farm. 2. Move over to column "F" and enter the table below: Cutoff Table ADG 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 3. 4. 5. 6. Net Loss Loss Loss Loss Break even Break even Break even Profit Profit Profit Profit With cell "C3" selected, click on the Activate the Function Wizard. In the "Lookup & reference" category, select "VLOOKUP" and click "OK". For the "Lookup_value" enter the cell "B3". For the "Table_array" enter the range of cells that contain the table you just entered. Just the numbers and Loss etc. do not include the headings. 7. Close the cell selection box. Intermediate Excel Exercises – Page 2. . 8. Hit the <F4> key to make the reference absolute. (Why?) 9. For the "Col_index_num" enter the value of "2" (no quotes). 10. Click the "OK" button. (What is displayed in cell "C3" now?) 11. Copy the function down the column. (Drag the handle!) Notice that everything in your functions is a reference except the value for "Col_index_num". There is no reason why that has to be a constant value! Let's make that a reference too. 1. Add another column to your lookup table as shown below: Cutoff Table ADG 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 Net Loss Loss Loss Loss Break even Break even Break even Profit Profit Profit Profit Action Have a nervous breakdown Sell the farm Hire a consultant Try to cut some costs Hope the price of feed drops Hope the price of pork rises Increase the herd size Relax Relax with a beer Relax with champagne Vacation in the Bahamas 2. In cell "D1" enter the text "Lookup column" and in "F1" the value "2" (no quotes). 3. Edit the formula in cell "C3" to extend the range to column "H". (Hint: Simply select the cell and make the change in the formula bar. Hit <Enter> when finished.) 4. Change the "2" at the end of the formula to make it an absolute reference to cell "F1".Copy the formula down the column. (Did the results change?) 5. Now change the value of cell "F1" to "3". (Did the results change now?) 6. Save this file (you can call it “Look_up” or something of your own choosing), we will use it again in a later exercise. Intermediate Excel Exercises – Page 3. . Exercise 3 Some Statistical Functions. Close all of the workbooks you may have open. If you really feel attached to them, you can save them on the floppy disk provided. Open the workbook "Muzak.xls" on the floppy disk provided. To save some time typing, this workbook contains the results from a series of experiments on the effect of Muzak on litter size in swine. (Yes it is fictitious - no experiment like this would ever have been approved by the animal use committee!) Each column of data represents the individual litter sizes of each sow exposed to the number of hours of Muzak in the top cell of the column. In this exercise, we will calculate the average litter size for each treatment, as well as the standard deviations. 1. Select cell B16. Here we will calculate the average litter size for the control group (Zero hours of Muzak). 2. Use the “Function” drop down list, choose the "Average" function and click the "OK" button. 3. Excel will probably figure that we want to calculate the average of the entire column. There are two ways to over-ride this selection. A) Edit the cell references in the formula bar; and B) Grab either of the top corners of the selection box and drag it down one row. Be careful to grab the corner. The cursor will be a diagonal double headed arrow when it is over the corner. 4. Hit the “Enter” key to complete the entry 5. Click on cell B17 to select it. 6. Now use the “Function Wizard” to enter the function "STDEVP" with the same block of cells as an argument. (Since the data in the spreadsheet represent the entire population of test animals, the function for the Standard Deviation of the population is appropriate. 7. Select both of the cells with functions and copy them across the columns to calculate the values for each treatment. (Note: all cell references in these functions are relative. Is this OK?) Save this file back to the floppy disk - we may use it for a later exercise! The next part of this exercise may have to be done as a demonstration, depending on whether or not the "Analysis Toolpak" has been installed for the copies of Excel on the computers provided. One of the "Add-ins" for Microsoft Excel, called "Analysis Toolpak" provides a "one click" method of carrying out a number of statistical analyses on your data. The "Analysis Toolpak" comes on the CD with Microsoft Office 2000 and later, but is not part of the default installation. To check for this add-in, go to the "Tools" menu and see if Intermediate Excel Exercises – Page 4. . the last item is "Data analysis …". If it is there, follow along with the rest of this exercise on your computer. If it is not, we’ll se if we can install it. Otherwise - just observe!. 1. From the "Tools" menu, choose "Data Analysis …". This brings up the dialog box shown on the right. From there you can select which statistical procedure you want to apply to your data. 2. For our example, we will choose "Descriptive Statistics" and click "OK" 3. In the next dialog box, click in the “Input Range” line and select the data on which you wish to calculate the statistics. (make sure you do not select the heading row or the calculated values at the bottom!) 4. In the bottom area of the dialog box, make sure the radio button for "New Worksheet Ply" is checked to place our results in a new worksheet and give it a name. 5. Also in the bottom area, check the box for "Summary statistics" to tell Excel what to calculate. 6. Click "OK" and it's done! Excel will create a new worksheet and insert a table with values for : Mean, Standard Error, Median, Mode, Standard Deviation, Sample Variance, Kurtosis, Skewness, Range, Minimum, Maximum, Sum, and Count Depending on the procedure selected in the first dialog box, different input and output ranges/values will be required. Intermediate Excel Exercises – Page 5. . Exercise 4 An Array Function We will calculate a frequency distribution using some of the data in the “Muzak.xls” workbook. 1. Open the “Muzak.xls” workbook on the disk provided. 2. In column H, enter the cutoffs for the upper limits of each frequency range. (Excel’s name for this set of Bins_Array Frequency numbers is the “Bins_Array”. (See table on right.) 0 3. Enter a heading for the frequencies in cell I1 3 (“Frequency” is a good enough heading!) 6 4. Select the range of cells indicated by the shading in 9 the table on the right. (Note: It is good practice to 12 select an extra cell below the last entry in the 15 Bins_Array. Excel will use this cell for the number of values above our specified ranges, if there are any.) 5. Activate the Function Wizard and select the “Statistical” category. 6. Find the function “Frequency” and select it. 7. For the “Data_Array” select the data in the “24 hours” of Muzak column. (Make sure you do not select the heading cell containing the value 24!) 8. For the “Bins_Array” select the values you just entered for the upper limits cutoffs. 9. While holding down the <Control> and <Shift> keys click the “OK” button. There are few enough values in our sample for you to check that Excel has calculated the correct frequencies. What happens when you change the values in the “Bins_Array”? What happens when you change some of the data in the 24 hour column? (Try changing one of the values to something beyond our expected range.) Intermediate Excel Exercises – Page 6. . Exercise 5 How to change the value of a cell You will work on the workbook you created earlier, in exercise 2 on the “VLookup” function. If you did not manage to finish exercise 2, there is a file on the floppy provided called “Sample_Lookup”. Use that instead. To complete the various parts of this exercise you will need to display the “Forms” toolbar. If it is not already displayed, click on the “View” menu and select “Toolbars”, then “Forms”. The “Forms” toolbar will be displayed as a floating toolbar, usually on the right side of the screen. We will also need some additional data for some of these controls to use. So that we are all using the same cells, enter the following: Cell D1 ............ Display type -> (That’s a hyphen and greater than to look like an arrow) Cell E1 ............ Delete any contents and add shading to make it easy to find Cell L1 ............ Display types Cell L2 ............ Simple Cell L3 ............ Verbose Cell L4 ............ None Cells I3:I13...... Enter a space (hit the spacebar once, more will not hurt!). This is to make sure that the column next to the last column of comments contain spaces. (Challenge! Can you do it to all of the cells at once?) The List box. Insert a “List box” in the spreadsheet, I suggest under the data on the left side, to leave room for the other controls. To add the List Box, click on the “List box” button on the “Forms” toolbar (left column, about the middle) and then click the left mouse button and drag over a section of the spreadsheet to “draw” the List Box. Make it about a cell and a half wide by three cells deep. When you let go of the mouse button you will see the empty List Box. To assign its list and link it to a cell, click on it with the RIGHT mouse button. This brings up a menu. Choose “Format Control” (last one on the list). In the dialog box that pops up, click on the line for “Input range” and select the three cells containing the words “Simple” , “Verbose” and “None”. Now click in the line for “Cell link” and select the blank cell you applied shading to (F1). Leave the “Selection type” at single. You can check the box for “3-D shading” or not – your choice. Now click the “OK” button to close the dialog box. You will have to click somewhere outside of the List Box to de-select it before you can see it work. The List Box should now contain the words “Simple”, “Verbose” and “None”. Click on each of the words in turn and note that the value in cell F1 changes with each click. Now we need something to change depending on the value of cell F1! Click on the cell that contains the first of the “Vlookup” functions (probably cell C3). Edit this cell so that the last item (a “2”) is now $F$1+1 (make sure the cell reference is absolute). We have to add 1 to the value of cell F1 because the List Box will only insert the values “1”, Intermediate Excel Exercises – Page 7. . “2”and “3”, but we need to choose “2”, “3” and “4” for the “Column index number” in the Vlookup function. Also change the range for the “Table_Array” to include one more column. The function (formula) should read “=VLOOKUP(B3,$F$3:$I$13,$F$1+1)”, the bolded characters are the required changes. (If your spreadsheet has parts in different locations from the sample, the following table should help you put the right data in the “VLOOKUP” function: Sample contents B3 $F$3:$I$13 $F$1+1 What the cells represent The cell containing the value to be looked up The table containing the text to be inserted as a comment The cell which will be controlled by the list box (+1!). This is the column index value in the VLOOKUP function Copy the newly edited cell down the column. Now click in the List Box and watch the table change. Combo Box Insert a “Combo box” in the spreadsheet, I suggest to the immediate right of the List Box. To add the Combo Box, click on the “Combo box” button on the “Forms” toolbar (right column, about the middle) and then click the left mouse button and drag over a section of the spreadsheet to “draw” the Combo Box. Make it about a cell and a half wide by two cells deep. When you let go of the mouse button you will see the empty combo Box. To assign its list and link it to a cell is exactly the same as for a List Box. Click on it with the RIGHT mouse button. This brings up a menu. Choose “Format Control” (last one on the list). In the dialog box that pops up, click on the line for “Input range” and select the three cells containing the words “Simple”, “Verbose” and “None”. Now click in the line for “Cell link” and select the blank cell you applied shading to (F1). You can have multiple controls affecting the same cell. Change the “Drop down lines” to 3, since we only have 3 values! (If you set this value to less than the number of items in the list you will have to scroll.)You can check the box for “3-D shading” or not – your choice. Now click the “OK” button to close the dialog box. You will have to click somewhere outside of the Combo Box to de-select it before you can see it work. Try it out! Use the down arrow to show the list and pick one. Notice when you change the value of cell F1 with the Combo Box, the display in the List box also changes. It’s all tied together. Scroll Bar Use the “Forms” toolbar to add a Scroll Bar to the spreadsheet. A good place to put it is right beside the Combo Box. It can be the same size as the other two control features. Once it is in place, RIGHT click on it and choose “Format control” from the pop-up menu to set its properties. The only values you need to change are: “Minimum value” – set it to 1; and “Maximum value” – set it to 3. (Note, if we had been doing this from scratch, we would have set the minimum to 2 and maximum to 4 so that the “Column Intermediate Excel Exercises – Page 8. . index number” in our Vlookup function would not have had to be the cell reference plus 1.) Set the “Cell link” to the blank cell you applied shading to (F1). The “Page change” value determines how much the scroll bar moves when you click between the bar and one of the buttons. With only three values in our example, set this to “1”. For long lists it may be more useful to use a higher number. After you get it working, try changing it to “2” to see what happens to its behavior. Spinner Go ahead and add a “Spinner” control to your spreadsheet. You will find it very similar to the scroll bar in function and setup. Which control to use? It is going to depend on how long the list is. A List Box only needs one click, but more than 3 or 4 in the list is going to make it big. A Combo Box takes up less space, but requires two mouse clicks to choose the value. The Scroll Bar and Spinner are good for moving sequentially through values. For long lists, the Scroll Bar allows you to drag the bar to the approximate value and the use the arrows to fine tune. Why not use more than one? Since multiple controls can act on the same cell and automatically update when the cell changes, a Scroll Bar to select a value with a Combo Box to display it may be a good choice. Personal preference will often determine your choice. Intermediate Excel Exercises – Page 9. . Exercise 6 Calculating loan payments In this exercise you will become familiar with entering and editing built-in Excel functions. You will be able to use formatting buttons on the “Formatting” toolbar. You will understand and be able to apply the concept of “Relative” and “Absolute” cell references. 1. Open a new, blank workbook 2. Enter a row of headings as a reminder of the values necessary to use Excel’s loan calculation functions. These are shown in the figure above. (Some of these values will be calculated to convert “normal” units to what Excel expects.) 3. In the row immediately under the headings, enter values for the Principal Amount, Annual Percentage Rate and Number of years to pay off the loan. By all means use your own figures: calculate car payments, figure out a mortgage! Since a loan is a negative amount of money, make sure you enter a minus sign before the principal amount, otherwise your payments and interest will be negative! Also – enter the interest rate as a decimal, e.g. 5% = .05. 4. Since Excel’s functions require monthly interest rates, enter the formula to calculate this in the appropriate cell (eg. = Rate (yrly)/12). 5. Similarly enter a formula to calculate the number of monthly payments (# years * 12) in the appropriate cell. 6. Enter a row of headings further down the spreadsheet for columns to list various aspects of monthly payments as shown. 7. Under the “Payment #” heading, enter a sequence of numbers from 1 to the total number of payments (or more if you want more options). 8. Under the “Total” column, enter the function to calculate the monthly payment (PMT{arguments}) (You will be copying this function down the column. How many of the cell references need to be absolute?) 9. Under the “Interest” heading, enter the function to calculate the amount of interest for the first payment (IPMT{arguments}). (Which references need to be absolute and which relative?) 10. Under the “Principal” heading enter a formula to calculate the amount paid to principal (Total minus Interest). (Think about absolute and relative!) 11. Under the “Balance” heading, enter a formula to calculate the balance left on the principal after the first payment (Original Principal PLUS the value in the “Principal Paid” column – remember that your loan is a negative amount). You can leave the cell references relative since you will need to enter a slightly difference version of this formula in the next row. Have you saved your work? Intermediate Excel Exercises – Page 10. . 12. Copy the formulae/functions for “Principal Paid”, “Interest”, and “Total” down one row. 13. Enter a formula to calculate the balance after the second payment. 14. Copy all of the formulae/functions down as far as you generated numbers. Quick Tip: Select the row you want to copy Scroll down to the bottom of your worksheet and <Shift>+Click on the bottom rightmost cell you want filled with the formulae Hold down the <Control> key and press the letter “D” (For “Down”!) Excel “Fills Down” the selected area with the requested formulae. Save your work! Play with your spreadsheet! Try changing some of your original values to see what it does to your total payment. What if you can re-negotiate the interest rate? What if you reduced the length of the loan? How about adding a “Sum()” function to see how much interest you pay over the length of the loan? Can you find the “hump” payment (when you start paying more off the principal than to interest)? You may wish to save this simple little spreadsheet for future use! Also included in the sample files provided is a much more sophisticated Load Repayment calculator from Microsoft’s Web site. The file is called “Loan_calc_from_Microsoft.xls”. Check it out to see what Excel can do, when you know what you are doing with it! Intermediate Excel Exercises – Page 11. .