Determining the Complexity of a Worksheet

Written by Allen Wyatt (last updated September 12, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021


1

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 development 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 eliminates 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 value of the model vs the actual for each individual value, divided by the sum of squares total, meaning the square of differences 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, 2013, 2016, 2019, and 2021.

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

Determining if Calculation is Necessary

When processing a worksheet with a macro, it may be helpful to periodically recalculate the worksheet. Wouldn't it be ...

Discover More

Changing Sections

When you divide your document into sections in order to change page layout attributes, you need to give some thought to ...

Discover More

Spacing Before and After Lists

When formatting a document that uses lists, you may want to adjust the space that appears just before and just after the ...

Discover More

Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!

More ExcelTips (ribbon)

Quickly Inserting a New Worksheet

Want a quick way to insert a worksheet? There's nothing faster than using the handy shortcut.

Discover More

Alphabetizing Worksheet Tabs

As you get more and more worksheets into a workbook, you'll find yourself moving them around into different sequences. ...

Discover More

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 ...

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}] (all 7 characters, in the sequence shown) 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 two more than 3?

2020-09-15 14:55:35

Ronmio

Allen said that the two formulas below are "functionally equivalent ".

=A1+A2+A3
=SUM(A1:A3)

That's only true if all the cells contain values. If some of the cells could legitimately contain text then =A1+A2+A3 would produce a #VALUE! error. To make that first formula functionally equivalent to the second one, it would need to be something like ...

=IF(AND(ISTEXT(A1),ISTEXT(A2),ISTEXT(A3)),"no values found", IF(AND(ISNUMBER(A1),ISTEXT(A2),ISNUMBER(A3)),A1+A3,
IF(AND(ISNUMBER(LA1),ISNU ...

So, in order to handle all the permutations of text and values, it could end up being a very long, complex formula.

The takeaway is that the SUM function tolerates text but standard math formulas with operands do not. But that doesn't mean you always want to use the SUM function. Having a formula catch text-value errors (e.g., the letter O instead of the number 0 in a value) where there should only be values could be critical. That's when you would want to use a simple math formulas with operands because it will make you aware of the text error.


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.