Finding the volatile function in my Excel sheet

2

I have a fairly large Excel sheet which keeps track of our golfcompetition. To speed up the sheet (for use on my old laptop) I am trying to limit the number of automatic calculations. E.g. the total score is only calculated if you enter the last hole.

However, my Immediate Window shows me there is a lot of calculation done after every entry. There seems to be a volatile function somewhere. I have searched and replaced all functions known to be volatile (I used to use INDIRECT and OFFSET). I have checked all my named ranges for OFFSET (and removed it). I have even replaced all ROW and COLUMN functions, even though MS claims they are not volatile.

Still Excel recalculates the whole sheet after every entry, and I cannot seem to find the source.

I use Excel 2016 (Dutch version) under Windows 7. I use a couple of UDF's (which give me feedback on the calculations going on) for simple calculations. All data for the UDF's is passed as parameters.

Is there any way to track the source of volatile calculations in a sheet?

My sheet can be found on http://www.wacgolf.nl/docs/WAC%202016.xlsm It is filled with testscores until sheet '25-6'. Upon entering any score in that sheet, the whole worksheet is recalculated.

I have isolated the calcChain.xml file, which should contain the calculation chain. But I fail to see where my problem starts. Any help is highly appreciated.

calcChain.xml

Joost

Posted 2016-03-09T10:11:31.990

Reputation: 120

1Are you able to share the spreadsheet in some form? – Jonno – 2016-03-09T10:24:59.613

Tracking results from a competition doesn't seem to be resources demanding. I'm afraid you've bigger issues, but as also Jonno is commented, it's difficult to say anything without looking the code. – Máté Juhász – 2016-03-09T10:38:33.543

@MátéJuhász You are right it should not be resources demanding. But as it stands now Excel recalculates every cell in the workbook after every entry in a cell. On my laptop that takes about a second to finish – Joost – 2016-03-10T11:43:34.217

What are your conditional formatting rules? Also you have data validation - does it rely on a range? Also I don't see any formulas on any of the sheets? – Raystafarian – 2016-03-10T12:38:30.113

This is clearly a macro-enabled worksheet, with some functions defined. If you're using those in worksheet calculations, that can be really slow. I would change those to pure worksheet functions if possible. – benshepherd – 2016-03-10T12:54:55.040

Answers

3

After some searching I concluded that it weren't my UDF's that were volatile. It turned out to be a reference in the form:

INDEX([named range],[row],[col])

If I replace that reference with a direct one ([sheet]![col][row]) the calculations stop. Whether it is the INDEX function or the named range or the combination of the two, I don't know. I use a lot of named ranges and a lot of INDEX references to the named ranges. I cannot replace them all to find out what is the matter. Btw, The named range is a fixed range. Offset() is nowhere used in my sheet.

Joost

Posted 2016-03-09T10:11:31.990

Reputation: 120

1

I now think this is probably wrong, see the comments below. UDFs are apparently considered non-volatile unless specifically marked as volatile.

Expanding on my comment, you're absolutely right about the volatile functions. But those volatile functions are your own UDFs - Excel cannot know whether they are volatile or not, and therefore has to treat them as volatile, recalculating them every time you make any change to the workbook. And because VBA is slow relative to worksheet functions, that will really slow your calculation down.

Try to replace your UDFs with worksheet functions if at all possible. You'll see a huge improvement in performance.

benshepherd

Posted 2016-03-09T10:11:31.990

Reputation: 1 448

@Benshepard, can you provide a source on this? The MSDN reference on volatility states otherwise. And quote: "By default, Excel assumes that VBA UDFs are not volatile. Excel only learns that a UDF is volatile when it first calls it.... " Typically, you define a UDF as volatile using Application.Volatile... https://docs.microsoft.com/en-us/office/client-developer/excel/excel-recalculation

– CBRF23 – 2019-08-05T18:00:00.903

Hmm, interesting. I just commented from my own experience. I didn't know about Application.Volatile. Is it a recent addition? – benshepherd – 2019-08-10T17:59:35.137

No clue - I looked it up after I saw your post. I remember using that command for something before so I just checked the reference to see what it was all about. – CBRF23 – 2019-08-10T19:03:12.567