I agree.
I found that when you turn off ScreenUpdating , Calculation , it’s better to think about how to do as much work (recording, reading, events, ...) as possible in a few calls of ScreenUpdating in return. This will speed up operations and also provide the user with a more convenient and more tolerant experience. Say, for example, that you want to write some data on a sheet as quickly as possible. You can do it:
For Each row In rowDic.Keys() ' turn off updating for item in rowDic.Key(row) ... do some writes Next ' turn on updating Next
or faster, you can do this:
' turn off updating For Each row In rowDic.Keys() for item in rowDic.Key(row) ... do some writes Next Next ' turn on updating
Similarly, when recording data, it is faster to write large chunks, less time. therefore, the ideal number of records, if any, is one. You can do this by treating Range as a 2D array[rows,cols] . I found the following to be effective:
' turn off updates ' Organise data in ram so that it fits the range for which it is meant Dim two_d_arr (rows,cols) loadDataFromSource two_d_arr Dim destinationRange as Range destinationRange = Sheets(someSheet).Range(someRange).Value = two_d_arr Redim two_d_arr(0,0) ' !!! RELEASE MEMORY ' turn on updates
There are no cycles, this optimizes each individual task time in the CPU, which leads to faster processing time and, in turn, it seems that excel is working fine (not a failure).
NTN
F
Frank
source share