BuZz
BuZz

Reputation: 17425

Excel VBA : How to override Sheet Calculation via its associated event?

in the Worksheet_Calculate event of my sheet (triggered on SHIFT+F9), I need to override the calculation process. More precisely, I want to disable the default sheet calculation to replace that by some custom calculation. I need to calculate some things, then load some things in between, then compute some other cells, etc... I don't want Excel trying to calculate everything because 1. that takes a while 2. it is useless in my process

Is this possible ?

Upvotes: 0

Views: 1979

Answers (1)

Charles Williams
Charles Williams

Reputation: 23505

One approach would be to switch to Manual Calculation mode in the Worksheet_Calculate event, (Application.Calculation=xlManual) do your custom calculation etc, then switch back to automatic calculation (Application.Calculation=xlAutomatic). You would also need to set Application.EnableEvents to false at the start and then back to true at the end to avoid repeated calls to Worksheet_Calculate

Upvotes: 1

Related Questions