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

Hiding Graphics

Graphics are a great addition to a worksheet, but there may be times when you don't want them printed. The easy way to ...

Discover More

Adding labels to a chart can make the information presented in the chart more understandable. Excel allows you to add ...

Discover More

Picking a Contiguous Range of Table Cells

Creating a table in Word is a relatively simple task. When you want to format or edit information in the table, often the ...

Discover More Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Jumping to a Specific Worksheet

Want to make fast work of moving from one worksheet to another? Here's how to do the task when you have a lot of ...

Discover More

Referencing a Worksheet Name

Excel provides ways to reference the column or row number of a cell, but it doesn't provide a built-in way to reference a ...

Discover More

Switching Headers in a Frozen Row

Excel allows you to "freeze" rows in your worksheet. What if you want the rows that are frozen to change as you scroll ...

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.

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 five more than 4?

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.