简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM