Using Spreadsheets to Solve Problems
Total Page:16
File Type:pdf, Size:1020Kb
Using Spreadsheets to Solve Problems
1.11 DESIGNING & USING WORKBOOKS WITH MUTIPLE WORKSHEETS
Thus far the workbooks we’ve used have contained only a single worksheet. As the sets of data inputs and calculations become more complex, the design of our workbooks will be critical to their ultimate usability and maintenance. This section will explore how to design your workbooks to be efficient and effective and how to execute workbook solutions requiring multiple worksheets.
DESIGNING EFFICIENT/EFFECTIVE SPREADSHEETS
This problem only required a simple single Excel worksheet. Frequently problems are more complex and require more and varied inputs, multiple calculations, and even multiple solution cases. What other techniques can be used to best solve complex problems using an Excel workbook? This section will look at some of the tools that are available to us in modern day spreadsheets, including the use of multiple worksheets, 3-D formulas, and a technique that allows us to work backwards to determine what input value is required for a desired output value.
Before beginning any workbook, planning a design is critical to implementing an effective solution. Good planning will help avoid time consuming changes later. There are three main reasons why a spreadsheet solution may require changes:
It is difficult to read and use.
It does not allow additional variables to be easily included.
It does allow values to be easily changed.
The next few sections provide guidelines that can prevent a spreadsheet from having any of these three problems.
THE FIRST RULE – LIST DATA INPUTS
There are several concepts that should be taken into consideration when designing effective spreadsheets. One such concept, that has already been discussed previously, is the use of formulas that reference input values rather than use constants. Data should never appear more than once in a spreadsheet. In previous chapters we have seen how this allows us to easily make changes and updates. A B C D Figure 2 contains the identical worksheet as 1 Job #1: $/hour $/year 2 rate $ 9.00 $ 8,550.00 Figure 1 but with several changes: 3 hours per week 19 4 weeks per year worked 50 5 The number of hours per week worked is 6 Job #2 changed for Job1 (B3) from 20 to 19. 7 rate $ 8.60 $ 8,600.00 8 hours per week 20 9 weeks per year worked 50 10 11 Should he switch? don't switch
Designing Workbooks 1.11 CSE1111 Page 1 Using Spreadsheets to Solve Problems
The annual salary for job 2 (D7) is modified to $8600.
Once these values are input into cell B3 and D7, all affected values are automatically updated. Both Job 1 $/year (D2) and Job 2 $/hour (C7) as well as the determination as to whether or not to switch are automatically updated. The user does not need to know specifically which cells are affected by the changes.
This type of analysis, in which alternative values are substituted for data inputs, is known as a “what-if” analysis. A well designed spreadsheet will allow the user to vary one or more values to determine how they will affect the solution.
VERTICAL VERSUS HORIZONTAL ORIENTATION
A B C D E In Figure 2 the data is presented with each hours per weeks $/hour $/year Job listed in a separate table. Two week per year alternative configurations can be seen in 1 worked 2 Job #1: 20 50 $ 9.00 $ 9,000.00 Figure 3. The top worksheet shows data 3 Job #2 20 50 $ 8.50 $ 8,500.00 organized with each category as a separate 4 Should he switch? don't switch column and each job as a separate row. A B C The bottom worksheet shows data 1 Job #1: Job #2 organized with each category as a separate 2 $/hour $ 9.00 $ 8.50 row and each job as a separate column. 3 hours per week 20 20 4 weeks per year worked 50 50 Which configuration is best? That answer 5 $/year $ 9,000.00 $ 8,500.00 6 depends on the data being presented, its 7 Should he switch? don't switch readability, and ease of maintenance. In general if you have 4 categories and 200 jobs, it would be best to use a configuration similar to the bottom worksheet, with the columns listing the categories and the rows the jobs. If you have 4 jobs and 200 categories, it’s best to put the jobs as the column headings, as is the case with the top worksheet. But this rule of thumb assumes common categories. In some cases there are different input categories for each calculation, making these formats difficult. In such cases making separate tables, as seen in Figure 2, is a better option.
What if data is shared between calculations but never varies from one calculation to another? This is the case when listing common constants such as inches per foot or ounces per pound. Often this type of data is placed in a separate input area where it can be updated in only one location. For example if 50 work weeks per year is common to all jobs, this value can be placed in only one cell. If the number of weeks varies from job to job, it should be listed as a separate input for each job. Knowing if a value may vary from case to case will help a designer select a robust design that is flexible enough to maintain.
To accommodate different inputs and cases, the spreadsheet designer has the ability to do the following:
1. Add additional columns.
2. Add additional rows.
Designing Workbooks 1.11 CSE1111 Page 2 Using Spreadsheets to Solve Problems
3. Create additional “tables” on a worksheet. These “tables” can be placed anywhere on the spreadsheet in additional columns, rows, etc. and can vary in format as the data inputs vary.
4. Create additional worksheets in the workbook.
5. Create additional workbooks.
USING MULTIPLE WORKSHEETS – INPUTS & OUTPUTS
Perhaps Alex has been lucky enough to be offered six different jobs with varying wages, hours, and overtime opportunities. He now has six different $/hour values, six different numbers for hours per week, six different numbers for weeks per year, etc. As we’ve seen, there is no one right way to organize this information. Each layout will offer its own advantages and disadvantages. It will partly depend on how the data ultimately needs to be presented, and what information is likely to vary and which is not.
One method of organizing this information in a workbook is with inputs and outputs on separate worksheets. Often when there are many varying inputs several worksheets are used, with each set of inputs on a separate worksheet and another worksheet for outputs. As seen in Figure 4, two worksheets have been used for this simple example. The worksheet Inputs! lists the wage and hour information for each job offer. Sheet Calc! contains the calculations for weekly pay including overtime at time and a half (1.5) and double time (2) as well as annual wages.
A B C D E F G 1 Job #1: Job #2 Job #3 Job #4 Job #5 Job #6 2 $/hour $ 9.00 $ 8.00 $ 7.50 $ 9.50 $ 10.00 $ 15.00 3 regular hours per week 40 35 40 35 15 12 4 weeks per year worked 50 50 52 50 50 52 5 average OT hours/week at 1.5x 5 0 10 5 0 0 6 average OT hours/week at 2x 1 0 0 0 3 0 A B C D E F G 1 Multiplier for 1.5x 1.5 2 Multiplier for 2x 2 3 4 Job #1: Job #2 Job #3 Job #4 Job #5 Job #6 5 Regular wages per week $ 360.00 $ 280.00 $ 300.00 $ 332.50 $ 150.00 $ 180.00 6 OT wages/week at 1.5x $ 67.50 $ - $ 112.50 $ 71.25 $ - $ - 7 OT wages/week at 2x $ 18.00 $ - $ - $ - $ 60.00 $ - 8 Total Wages per week $ 445.50 $ 280.00 $ 412.50 $ 403.75 $ 210.00 $ 180.00 9 Total Wages per year $ 22,275.00 $ 14,000.00 $ 21,450.00 $ 20,187.50 $ 10,500.00 $ 9,360.00 This configuration is excellent for comparing categories of values, as outputs are together and inputs are together. It’s easy to compare the $/hour, the hours per week, or even the total wages per year across the different job offers. Even though some absolute cell referencing is required, it is also convenient for copying formulas, as similar formulas are located in adjacent cells.
Remember when writing formulas that reference cells on other worksheets, the cell address must be preceded by the sheet name and an exclamation point. For example, the formula in cell Calc!B6 which calculates overtime wages paid at time and a half (1.5x) references both the $/hour and average overtime hours per week values on the Inputs! worksheet. To reference these values, the formula =Inputs!B$2*$B1*Inputs!B5 precedes these references with the
Designing Workbooks 1.11 CSE1111 Page 3 Using Spreadsheets to Solve Problems
Input! sheet reference. The reference to the 1.5 OT multiplier is on the same worksheet as the cell where the formula is written and does not need a sheet name.
Note that common “constants” such as 1.5 and 2.0 are listed in a separate location from the other variable inputs. These could have just as easily been placed on the worksheet Inputs! or even on a separate worksheet. The layout used here is excellent in cases where additional calculations are later required, such as adding hours per week of overtime at 3 times the regular wage rate. However, it’s not as easy to add new jobs. Additional jobs will require changes be made to both of the worksheets and formulas copied into new column. It is frequently the case that flexibility with respect to one concern is sacrificed to make another more flexible or easier to read/use.
One more note regarding this input/output layout. This layout should not be used if the data needs to be presented in a case by case layout, where all inputs and outputs from a specific case need to be presented together (i.e., Job1 on one sheet, job2 on a another sheet, etc.). In such a situation a case by case layout may be preferable. Designing such solutions will be discussed in a subsequent section.
DISPLAYING MULTIPLE WORKSHEETS IN THE EXCEL WINDOW
One tip when writing formulas with multiple worksheet references is to display these worksheets simultaneously on your screen. This can be accomplished by opening new worksheet windows within the Excel window and sizing each as needed. A diagram of a single maximized worksheet in the Excel window can be seen in Figure 5. Figure 7 is a diagram showing multiple sized worksheet windows within the Excel window. The steps to get from the display in Figure 5 to the display in Figure 7 are follows:
If the worksheet is maximized within the Excel window, click on the Restore Worksheet
Window Button in the upper right corner of the worksheet window.
Once the worksheet window is no longer maximized, Excel allows the user to size the worksheet. When the cursor hovers over any edge of the worksheet window it will turn into a
Designing Workbooks 1.11 CSE1111 Page 4 Using Spreadsheets to Solve Problems
sizing handle (two sided arrow). Clicking and holding when the sizing handle is displayed allows the user to drag the cursor up/down to adjust the height of the window and left/right to adjust the width of the window. Size the window to show only the necessary headings and data, leaving ample room in the Excel window for other worksheets to be displayed. To open a second window, select the View Ribbon Tab and select the New Window button from the Windows group. A second window will now be visible within the Excel window. To display the desired worksheet, click on the sheet tab of the worksheet you wish to display and then size this window as needed. Repeat the previous step, until as many windows as needed (or as possible to view) are displayed. In this case the Inputs! worksheet window and the Calc! worksheet window can be arranged side-by-side, as seen in Figure 7.
When writing formulas that references a cell on one of these other worksheets, just click on the worksheet cell needed and it will be automatically inserted into the formula with the appropriate sheet name.
Designing Workbooks 1.11 CSE1111 Page 5 Using Spreadsheets to Solve Problems
USING MULTIPLE WORKSHEETS – CASE BY CASE METHOD
An alternate workbook design configuration which is better for displaying an entire case, with all inputs and outputs for that case, can be seen in Figure 8. Here each job is placed on a separate worksheet.
Setting up layouts where each case has identical input categories and calculations is extremely easy. First create the worksheet for Case 1 (in this instance Job1). Then write the appropriate formulas as needed. Make sure not to use sheet names to reference items contained on this Job 1 sheet. Then once the calculations are complete and the worksheet formatted appropriated, copy the entire worksheet as many times as needed and simply modify the input values. One method of copying an entire worksheet is as follows:
To select the worksheet click on the sheet selector button located just above the row number 1 and to the left of the column label A.
Use the copy feature to copy the worksheet: either click the copy icon in the Clipboard Group of the Home Ribbon or press Ctrl+C (control key and the C key held down simultaneously).
If necessary, insert a new worksheet using the Insert Worksheet button to the right of the sheet tabs at the bottom of the worksheet.
In the new worksheet, use the paste features to paste the data (the paste icon in the Clipboard Group of the Home Ribbon or Ctrl+V).
Once the worksheets are copied, name each sheet appropriately (Job1, Job2, etc.) and substitute the corresponding input values. The calculations will automatically be updated on each worksheet as the formulas will reference the values on the corresponding sheet.
The major disadvantage of this method is if new variables are needed, for example OT hours at 3x the $/hour pay rate, each would then need to be added to each worksheet. In an upcoming section a method for accomplishing this task will be discussed.
What if you still need each job to be displayed in separate tables but still wish to compare the total values across cases? Instead of designing two sets of worksheets for each configuration (inputs/outputs vs. case by case) one can set up a summary sheet from the case by case worksheets. This is especially simple if the values for each element are always located in the
Designing Workbooks 1.11 CSE1111 Page 6 Using Spreadsheets to Solve Problems same cell. In this case, the cost elements are the same in each case and reside in the same relative location: the total wages is always in cell B19 on each worksheet. In instances where each case has different elements, each case could be setup as needed but the summarizing of the data would not be as trivial. The next section will discuss just how to easily set up this type of summary using 3-D formulas.
USING 3-D FORMULAS TO CREATE SUMMARIES
When inputs and outputs are placed in separate areas of the workbook it is easy to compare and aggregate data between different cases. To similarly compare and aggregate data when organizing each case is on a different sheet in the workbook, a summary worksheet can be setup using 3-D cell referencing. A B C Figure 9 is a summary of the six job offers, 1 Calculations: Total Average 2 Regular wages per week $ 1,602.50 $ 267.08 where data categories to be aggregated are in 3 OT wages/week at 1.5x $ 251.25 $ 41.88 column A. The total values for each category 4 OT wages/week at 2x $ 78.00 $ 13.00 are calculated in column B, and the average 5 Total Wages per week $ 1,931.75 $ 321.96 6 Total Wages per year $ 97,772.50 $ 16,295.42 values for each category are in column C.
The simplest method to create such a summary is to first copy the titles from the output section of any individual case to a new worksheet. If the category descriptions are listed down a column, keep that configuration. Similarly if the category descriptions are listed across rows, copy them in the same configuration. Figure 10 displays the summary categories in a vertical list.
To total the values for the wages per week category for all six jobs, write the following formula in cell B2: =Job1!B15+Job2!B15+Job3!B15+Job4!B15+Job5!B15+Job6!B15. Since the order of the categories matches those in each of the six case worksheets, this formula can then be copied down the column to calculate the values for OT wages/week at 1.5x, OT wages/week at 2x, etc. The cell references will change relatively but the sheet names will remain the same.
A trick to writing this formula in cases where there are many worksheets is to use a range of cells spanning multiple sheets: =SUM(Job1!:B15:Job6!:B15). This will only work if the sheets are adjacent to each other in the workbook. Using this second method, assuming these worksheet tabs are all adjacent to one another, write the formula =AVERAGE(Job1!:Job6:B15) to obtain the average value of regular wages as follows:
To simultaneously select multiple adjacent worksheets complete the following steps:
On the summary worksheet (Figure 6) select cell C2 and begin writing the formula as usual =AVERAGE(
At the point where you are ready to enter the range, click on the appropriate cell (or cells) in the 1st worksheet of the range, in this case Job1!B15.
Designing Workbooks 1.11 CSE1111 Page 7 Using Spreadsheets to Solve Problems
Hold down the shift key and then using the mouse, click on the tab of the last worksheet to be included in the range and then press Enter.
Complete the formula by typing a close parenthesis.
This formula =AVERAGE(Job1:Job6!B15) may also be typed out using the keyboard, though errors can be introduced when doing so. Later, additional Jobs can be added to these totals by simply adding a worksheet somewhere between the worksheet tab range in the formulas. But be careful – if you add a worksheet somewhere among Job1 through 6 that should not be included, errors will occur.
What if a more detailed summary is desired, as seen in Figure 10? This summary is more like the comparisons setup using the first layout where data inputs are on one page and outputs are on another. With the case by case method workbook layout this type of summary is also easy to set up.
Calculations: Job1 Job2 Job3 Job4 Job5 Job6 Total Average Regular wages per week $ 360.00 $ 280.00 $ 300.00 $ 332.50 $ 150.00 $ 180.00 $ 1,602.50 $ 267.08 OT wages/week at 1.5x $ 67.50 $ - $ 112.50 $ 71.25 $ - $ - $ 251.25 $ 41.88 OT wages/week at 2x $ 18.00 $ - $ - $ - $ 60.00 $ - $ 78.00 $ 13.00 Total Wages per week $ 445.50 $ 280.00 $ 412.50 $ 403.75 $ 210.00 $ 180.00 $ 1,931.75 $ 321.96 Total Wages per year $ 22,275.00 $ 14,000.00 $ 21,450.00 $ 20,187.50 $ 10,500.00 $ 9,360.00 $ 97,772.50 $ 16,295.42 Cells B1:G1 each contain cell references to the values calculated on the individual worksheets; =Job1!B15 in cell B1, =Job2!B15 in cell C1, etc. These formulas are then copied down the column. The totals and averages are easily obtained from this summary worksheet. Why not just copy and paste the data from each job worksheet as values instead of referencing the cells? References ensure that if any data input or calculation changes on an individual case, the summary will be automatically updated.
Changing the Orientation of the Data: What if you have listed your data in a vertical format but wish to present your summary in a horizontal format? It can be tedious writing each formula out across a row when they cannot be copied down the column to match the data inputs. A temporary solution is to create the vertical summary and then copy it, use paste special and choose Values Only and the Transpose options. This will copy the summary values and simultaneously change the orientation of the presentation. It’s temporary because you need to copy values and since they’re values, any changes to the worksheet will render the summary incorrect.
Designing Workbooks 1.11 CSE1111 Page 8