Determining the Complexity of a Worksheet

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:

=A1+A2+A3

This formula has either two or three evaluations, depending on how you count evaluations. Now consider the following formula:

=SUM(A1:A3)

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Shortcut to Move between Two Worksheets

Moving between to adjacent worksheets is easy; Excel provides a shortcut key to do the trick. If you want to move between two ...

Discover More

Workbook Events

You can create macros that run whenever Excel detects a certain event happening within an entire workbook. This tip explains ...

Discover More

Entering Data as Thousands

There are many different ways you may need to enter data in a worksheet. For instance, you might want to enter data in ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Moving from Sheet to Sheet

Need to move quickly through the worksheets in a workbook? Learn the keyboard shortcuts and you can make short work of this ...

Discover More

Returning a Worksheet Name

Need to know the name of the current worksheet? You can use the CELL function as the basis for finding this information and ...

Discover More

Jumping to Alphabetic Worksheets

Got a workbook with a lot of worksheets in it? Here are some handy ways to jump to the worksheet you want, alphabetically.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine more than 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.