by Allen Wyatt
(last updated February 13, 2017)
Joran is doing a comparison of 13 different models of student financial aid (by provinces/territories in Canada). Each model has its own worksheet which feeds into a summary page. Joran would like to be able to compare the complexity of each individual worksheet (province/territory) in a concrete way. When using the 'Evaluate Formula' tool, each step of a given formula is isolated. He would like to know if there is a way to count the number of evaluation 'steps' contained in an entire spreadsheet. This would provide Joran with a somewhat objective measure that would be comparable across the workbook.
Unfortunately, it appears that Excel doesn't make the 'Evaluate Formula' tool available, as an object, within VBA. That means that to evaluate a worksheet in this manner would require developing a macro to look through all the cells, pull out formulas, and count the "functional phrases" in each formula. This could become rather complex in short order.
Even though this could be done (complexity aside), it may not produce the desired results. As an example, consider the following formula:
This formula has either two or three evaluations, depending on how you count evaluations. Now consider the following formula:
This formula is functionally equivalent to the previous one, but it requires only one evaluation. Neither formula is more complex than the other, but if you only count evaluations, the first would show as two or three times as complex as the second. Some functions, even though counted as a single evaluation, are much more complex than simple addition and this is also ignored when simply counting phrases.
Further, if your formulas include any type of decision-making structure (typically using the IF function), then the complexity of the formula isn't directly tied to the number of phrases or evaluations in the formula. The reason is because what Excel actually calculates is determined at the time of calculation based on the conditions present at that time.
Recognizing that counting phrases isn't the best way to determine model complexity naturally leads to the question of how one can make the determination. What can be examined within a worksheet to objectively determine complexity. There is no easy way to make such a determination. This is explained, in part, by Steve, an ExcelTips subscriber who is a PhD developmet chemist. As part of his work he designs experiments and analyzes them to create logistical and business models. Here's his comments:
===[begin Steve's comments on model complexity]===
A simpler evaluation of the complexity of the model, is the number of terms used in the model to get the results. When evaluating models, in my experience I have found that you want to find a balance of simple vs results. One adds elements that provide real substance to the results, and elminates those that do not.
A measure of fit used in models is termed the coefficient of determination (also known as R^2, R-squared). It is a measure of how well the model fits the actual data. It is the ratio of the "sum of squares" of the regression, meaning the square of the the value of the model ves the actual for each individual value, divided by the sum of squares total, meaning the square of differenced of each point to the mean of the points.
But as one adds complexity (by adding additional terms) the R^2 get higher as the degrees of freedom go down. An adjusted R^2 is good comparison:
Adjusted R^2 = 1 - (1-R^2) * (n-1) / (n-k-1)
where R^2 was as described above, n is the number of points, and k is the number of terms used in the model.
Typically one strives for the maximum adjusted R^2.
===[end Steve's comments on model complexity]===
Unless one is highly conversant in statistical methods and math, it is easy to get lost in the details of determining complexity in this manner.
If going down such a trail is not to your liking (or your training), then there is another way of determining complexity: How long does it take to arrive at a result using each model? If you put each model's worksheet into its own workbook, you can use a macro to measure how long it takes to perform a recalculation on the workbook. Since Excel uses the same internal methods to perform recalculation on each workbook, you can easily compare timing on each of the workbooks. For a general, seat-of-the-pants indication of complexity, the workbook that takes the longest to recalculate is the one that is most complex.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13096) applies to Microsoft Excel 2007, 2010, and 2013.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Want a quick way to insert a worksheet? There's nothing faster than using the handy shortcut.Discover More
Excel allows you, in your formulas, to include references to cells on other worksheets. Those references include the name ...Discover More
Not all spreadsheet programs are created equal; there are some things that can be done in others that can't be done in ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.