Search code examples
performanceexcelexcel-formulaprocessing-efficiencyarray-formulas

How to measure Excel Calculation times


For example how could I find what formula is faster?

=SUMPRODUCT((Data!D:D="RC Corp")*(Data!AD:AD="Expected Allowances / Provisions"))

Vs

=COUNTIFS(Data!D:D,"RC Corp",Data!AD:AD,"Expected Allowances / Provisions")

Vs Concatinating the 2 fields into a new Column and doing

 Z1 = D1&AD1
=Countif(Data!Z:Z,"RC CorpExpected Allowances / Provisions")

Vs VBA

Dim i as integer
Dim Total as integer
Total = 0 
i=0
While i < 1000 
    IF Range("D"&i).Value = "RC Corp" AND Range("AD"&i).Value = "Expected Allowances / Provisions" Then
Total = Total + 1
End If 
Wend
Range("$A$1").Value = Total

Solution

  • Woking from evocandy's answer I came up with this basic code.

    time1 = Timer
    Range("A1").Calculate ' Or the cell containing the Formula I want. OR use Sheets("Sheet1").Calculate for the calculation including concated columns
    time2 = Timer
    
    CalculationTime = Time2-Time1
    

    In order for this to work i had to Isolate sample data to new empty worksheets and disable the Automatic Refresh in Excel as to make sure it doesn't time any other Calculations.