Codematic Excel developers logo
Codematic spreadsheet-excel development image

Rapid Application Development / Advanced Excel Development

Products for Excel
Commercial Products:
  - Classic Ribbon
  - Alt-FileSearch
  - Password Remover
Spreadsheet Quality Products
Free Products
Excel Development
Excel Development Index
Excel VBA
- VBA IDE (editor)
- VBA Training
- VBA Best Practice
- VBA Performance
- COM Performance
- VBA Security
Excel and Databases
Excel and Pivot Tables
Excel Add-ins
Worksheet Functions
Excel and xlls
Excel (in)security
Excel testing
Excel and .net
Excel External Links
Excel Developer Types
Professional Excel Development
Excel 2007
Excel 2010
Excel Development Archive
Spreadsheet Services
Spreadsheet Development
Spreadsheet Migration
Spreadsheet Maintenance
Spreadsheet Review
Spreadsheet Management
Excel User Confs
Consultant Profile
Book Reviews
Site Map

Excel Calculation Counter

Excel Calculation

If used in automatic calculation mode (our preferred mode) Excel recalculates pretty much every time anything happens. Luckily Excel uses some pretty sophisticated rules to work out which parts of a workbook it actually needs to calculate. If you edit a cell, then roughly speaking Excel will only recalculate any cells that depend on that one and any that depend on those ones, and so on.

There are some functions where Excel cannot tell if their precedents have changed. The most obvious example is the INDIRECT function. This takes a string, tries to convert it to an address, if it succeeds it returns the value found at that address. If you try to audit an INDIRECT function you will see that Excel does not evaluate the passed in argument and report the result as a dependent, it just shows none. Other functions like this include OFFSET, RAND, NOW among others.

Volatile Functions

These functions are known as volatile. Because Excel can't use its smart calculation rules to know when it doesn't need to calculate them, it calculates them every time it calculates.

For a small number of formulas the performance impact will not be noticeable. If a workbook contains a large number of volatile functions, even small edits in unconnected areas will result in a significant recalculation. Bear in mind Excel calculates all open workbooks, not just the active one that is being edited.

VBA User Defined Functions (UDFS) are sometimes set up as volatile (by including the line

Application.Volatile = true

at the start of the function). Codematic do not recommend this, but some people feel the advantages outweigh the disadvantages (it can reduce the number of passed in parameters making it easier for end users, but at a cost of calculating with every minor change).

To get a sense of the cost of marking a function as volatile, or using volatile Excel functions we built a simple fast xll UDF in C. The function just keeps count of the number of times its been called. Its registered with Excel as volatile so it calculates and increments every time Excel does any sort of calculation for whatever reason.

The function is trivial:

long int lCount = 0;

EXPORT long int VolatileCalcCount ( void )
return ++lCount;

The results are interesting - in a normal spreadsheet editing session Excel can calculate 200 times or more an hour. If there are lots of volatile functions, or some slow ones (any VBA UDF is likely to be slow) that could mean anything from a noticeable pause when entering data, to an unusable many seconds (or minutes!) delay. One solution often suggested is to turn calculation to manual. The codematic view is that defeats the object of using a spreadsheet, and most of the time will lead to someone somewhere using uncalculated values by mistake.

To use the xll, simply double click it to open it then enter the following formula in a cell somewhere:

You can also find it under Codematic Functions in the Function Wizard.

The calculation counter xll is a free download available from here.

Any comments, feedback or suggestions welcome here.




Upcoming Events:

25 January 2012 - UK Excel Developer Conference - London

Products for sale:


Office 2007 FileSearch replacement logo

New information about the missing FileSearch feature in Office 2007 and details of our pragmatic solution (Current price GBP 30.00)


worksheet password remover logo

Instant Excel worksheet protection remover and password recovery (Current price GBP 15.00)

Classic Ribbon Tab

classic ribbon for office 2007 logo

Add Excel 97/2000/2002/2003 compatible menu structure to Excel 2007
(Current Price GBP 10.00)


Products coming soon:

Link Manager

(Find and control external links in Excel Workbooks)

Due by Q1 2111.

XLAnalyst Pro

(Excel VBA based spreadsheet auditing tool)

Due before the end of 2111.

This page was last reviewed on December 21, 2011

©Codematic Ltd 1999-2011