I have a pretty time consuming Excel macro, with a lot of input data. First, i load these data into an array (arr).
Is this code
for n =1 to 1000000
...
arr(n,1)=arr(n,2)+arr(n,4)*arr(n,78)
...
next n
faster than this
for n =1 to 1000000
...
Sensor_Top=arr(n,2)
Age =arr(n,4)
Material =arr(n,78)
output =Sensor_Top+Age*Material
arr(n,1) =output
...
next n
?
So in other words, i would like to include unnecessary variable declarations for readability. Does VBA do some sort of JIT compiling to deal with this?
arrcame from a worksheet, why wouldn'tarr(n, 1)be precomputed on the Excel worksheet in the first place? Why write any code to do a calculation whose result you can readily grab along with the rest of the data?