1

例如,我怎样才能找到更快的公式?

=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 将 2 个字段连接到一个新列中并做

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

与 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
4

2 回答 2

4

从 evocandy 的回答中醒来,我想出了这个基本代码。

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

为了使其工作,我必须将示例数据隔离到新的空工作表并禁用 Excel 中的自动刷新,以确保它不会为任何其他计算计时。

于 2013-03-06T17:18:01.877 回答
2

在 VBA 中,您可以使用Timer.

time1 = Timer
'Your code
time2 = timer

totaltime = time2-time1
于 2013-03-06T16:00:47.343 回答