• Embed Doc
  • Readcast
  • Collections
  • 1
    CommentGo Back
Download
 
Copyright © 2005 by Philip L. Bewig of Saint Louis, Missouri, USA. All rights reserved. This work is available under the Creative Commons Attribution-NonCommercial-NoDerivs License. For information regarding this license, visit http://creativecommons.org/licenses/by-nc-nd/2.0/ or write to CreativeCommons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Excel is a registered trademark of Microsoft Corporation.
How do you know your spreadsheet is right?
Principles, Techniques and Practice of Spreadsheet Style
Philip L. Bewig — July 28, 2005
You know it’s true: Spreadsheets have errorslike dogs have fleas.
1
It is generally accepted
2
 that nine out of every ten spreadsheets suffersome error, and consequences can be severe:
3
 
A cut-and-paste error cost TransAlta $24 millionwhen it underbid an electricity-supply contract.
4
 
A missing minus sign caused Fidelity’s MagellanFund to overstate projected earnings by $2.6 billion(yes,
billion
) and miss a promised dividend.
5
 
Falsely-linked spreadsheets permitted fraud totaling$700 million at the Allied Irish Bank.
6
 
Voting officials reported spreadsheet irregularities inNew Mexico
7
and South Africa.
8
 
A new drug introduction was delayed several monthsby an untested macro, costing the pharmaceuticalcompany profits and its patients misery.
9
 
You can’t eliminate errors from the spreadsheetsyou develop, but you can reduce their number.The principles and techniques described below,applied consistently, will improve the quality of your spreadsheets. The discussion assumes Ex-cel, but the principles and techniques apply eve-rywhere. The spreadsheet shown below will beused as a practical example:
Think before you write.
Resist the urge to jump right in to actual development. Start witha clear understanding of the requirements of your task. Sketch your design on a whiteboard,and look for flaws. Consider alternate softwaretools such as databases,
10
statistics packages,
11
 financial modeling systems,
12,13
business intelli-gence systems,
14,15
mathematical programminglanguages,
16,17,18
and traditional computer pro-gramming languages. This is the most funda-mental level of your work, and the most creativemoment in the entire existence of your spread-sheet. An error here can be hard to fix, requir-ing massive rearrangements of the spreadsheetstructure or new inputs from new sources.
 Know the players.
The
reader 
sees the printedoutput, and uses it to make a decision; he relieson you to organize and present the data heneeds, as he needs it. The
user 
inputs data, op-erates macros, and prints output, but doesn’tmodify anything; he relies on you to provideadequate instructions. You, the
developer 
, de-sign and implement the structure and all theformulas in the spreadsheet. The
auditor 
checksthe work of the developer; he relies on you toproduce a clean design and good documenta-tion. The
sponsor 
assigns the task, provides re-sources, and has overall responsibility for thespreadsheet; he relies on you to meet his speci-fications. In many cases some of these rolesoverlap; keep them all in mind as you developyour spreadsheet.
Make your spreadsheet as simple as possible,but no simpler.
19
 
Most spreadsheets work wellenough with a few
SUM
s and
IF
s, and usingfunctions like
SUMPRODUCT
or features like arrayformulas, or writing your own macros and func-tions, can make a spreadsheet harder to read andunderstand than it should be. On the other hand,don’t “dumb down” your spreadsheet, feel freeto hide complex logic in user-defined functions,
 
How do you know your spreadsheet is right? Page 2and if some advanced feature will simplify yourtask, use it. Be wary of features just added to orchanged in the newest version of Excel, wherebugs are likeliest to lurk; for instance, the
RAND
 function has changed with each version of Ex-cel, and statisticians claim
20,21
it’s still not right.
Plan to throw one away; you will, anyway.
22
 Prototypes are useful for spreadsheet developersfor the same reason that scale models are usefulfor architects; they help you visualize what youare building. They can help you add meaning toill-defined specifications, demonstrate a partialsolution, or work out tricky formulas. Fre-quently, prototypes grow into a solution; some-times, the prototype
is
the solution, and thewhole problem need never be solved.
Design for change.
Few spreadsheets are still-born; most evolve and grow through countlessversions, then may be copied with a new namenext month when the process starts anew.Brooks says: “All successful software getschanged.”
23
The best place to plan for change isduring the initial design of the spreadsheet. Re-flection, described below, is a useful tool forimplementing that plan. Building a change-tolerant spreadsheet isn’t much harder thanbuilding the other kind, but so much better forthe poor fellow who has to modify your work;you’ll especially appreciate the initial effort if you are, yourself, that poor fellow.
Keep input, logic, and reports in separatesections of a spreadsheet, preferably on dif-ferent tabs.
24
That way you can always see theassumptions neatly in a single place, formulasare less likely to be overwritten, you knowwhere to go to make changes, and output can beformatted for the reader while logic can be laidout for the developer. If you can’t put the threesections on separate tabs, arrange them on a sin-gle tab in a stepped diagonal so that rows andcolumns can be inserted or deleted in each areawithout affecting the other areas. But bewarethe false modularity of separate worksheets;since all cells in a worksheet are globally read-able, and globally writeable with a macro, usingseparate worksheets hides no information.
25
 Worksheets can’t be “dropped in” and reused,nor can they be checked individually withoutreference to other worksheets.
 Keep your entire spreadsheet on a single tab,intermixing input, logic and reports.
26
 
Youcan’t see your whole spreadsheet at a glance if itoccupies multiple worksheets. Multiple sheetsmake formulas longer and harder to read be-cause the sheet name must be included. Theybreed spurious cells (cells that simply copyother cells without calculation, like
=R12C4
) be-cause the spreadsheet developer wants to see theprecedent cell. The auditing toolbar fails withmultiple sheets because arrows don’t go to off-sheet cells, and searches are confined to the se-lected worksheet. With input and logic inter-mixed, arcs of precedence are shortened.
Lay out your spreadsheet as determined bythe needs of your problem.
Obviously, thetwo previous suggestions conflict, and in fact nosingle design is always right; the size of thespreadsheet, frequency of off-sheet references,complexity of formatting, and many other fac-tors must all be considered. The sample spread-sheet has four sections: growth rates (input) atthe top of the first column, tax rate (input) in anunlabelled cell at the bottom of the first column,base values (input) and growth amounts (calcu-lated) in the top rows, and income statement(calculated) in the bottom rows. An alternatelayout would have base values in a section nextto growth rates, with formulas that copy basevalues into the calculation area of the spread-sheet; this design works well if there are manyinput values or the calculation section is large.Some people will object to the inclusion of fixedcosts twice on the spreadsheet, saying that oneor the other is spurious and should be removed,but that’s a consequence of separating logicfrom output; in some cases it will be sufficientto have only a single appearance of the number,but if logic and output are both large, it maymake sense to have the number appear twice.
 Make your spreadsheet read top-to-bottomand left-to-right.
All dependent arrows shouldpoint down, right, or somewhere in between.
 
How do you know your spreadsheet is right? Page 3One exception is when the beginning balance atthe top of one column depends on the endingbalance at the bottom of the previous column.
Build a complicated spreadsheet in stages.
 Let it grow, but always with a working partialsolution at hand. Test as you go,
27
so you haveconfidence in the pieces as well as the whole.Fix problems immediately; don’t leave them forthe next version.
Draw the dependency graph.
“A picture isworth a thousand words.”
28
The dependencygraph of the sample spreadsheet looks like this:
Beware the cascade effect.
The likelihood thata spreadsheet produces erroneous output is afunction of the error rate
e
for individual cellsand the number
n
of cells that must each be cor-rect in succession (a “cascade” of cells) in orderfor the whole spreadsheet to be correct.Mathematically,
29
this function is 1–(1–
e
)
n
,which grows asymptotically to 100%, as shownin the graph below; with a 5% error rate, even acascade of only six cells gives more than a 25%chance of overall error. You can reduce the cellerror rate by careful checking, but it’s generallyeasier to restructure the computation to reducethe length of the cascade. The sample spread-sheet has seventeen cascades, six of six cells,eight of five cells, two of four cells, and one of three cells, as shown in the diagram above(every cascade through
Pretax Earnings
countstwice, since it has two out-arrows); it also has aone-cell cascade for the year captions that is notincluded in the diagram.
02040608010001.0%2.0%3.0%4.0%5.0%0.0%25.0%50.0%75.0%100.0%
Cascadeerrorrat eCascade lengt hErrorrat e
 
Document the design of your spreadsheet ona separate
HOWTO
tab.
State the purpose of your spreadsheet in a single sentence. Include adrawing of the dependency graph. Make a listof all the individual tabs in your spreadsheet,and write a single sentence describing each one.State the source of all inputs (be specific: “Patat extension 3220 in the Sales Department”),and specify by name and job title all the peoplethat will see your output. Briefly describe youroverall design (if that takes more than a sen-tence or two, your design is too complicated)and point out any unusual or tricky spots. De-scribe macros and user-defined functions. In-clude instructions so someone else can changeinput and obtain output without your help. Up-date your documentation when the spreadsheetchanges.
BaseValueGrowthRateBaseValueGrowthRateBaseValueGrowthRateBaseValueGrowthRatePricePer UnitUnitSalesCostFixedCostSalesCost OfSalesPretaxEarningsTaxNetIncomeIncomeTax
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
02 / 15 / 2011This doucment made it onto the Rising List!
You must be to leave a comment.
Submit
Characters: ...