|
请问sumif函数在VBA中运算时速度超慢,据说可以用内存什么的加快运算速度,请问怎么写呀?(根据下面的代码)谢谢!
Sub ttt()
With sheet3
For i = 2 To 1000
.Cells(i, 12) = Application.WorksheetFunction.SumIf(Sheet1.[a:a], .Cells(i, 11), Sheet1.[b:b])
Next
End With
End If
End Sub
lgfcl 发表于 2015-8-17 13:49
单元格L2 金额取不出来?
可以了。 - Sub ttt()
- Dim arr, Dic
- arr = Sheet1.UsedRange
- Set Dic = CreateObject("scripting.dictionary")
- For a = 2 To UBound(arr)
- Dic(arr(a, 1)) = Dic(arr(a, 1)) + Val(arr(a, 2))
- Next
- arr = Sheet3.Range(Sheet3.[L2], Sheet3.Cells(Rows.Count, "K").End(3))
- For a = 1 To UBound(arr)
- arr(a, 2) = Dic(arr(a, 1))
- Next
- Sheet3.Range(Sheet3.[L2], Sheet3.Cells(Rows.Count, "K").End(3)) = arr
- End Sub
复制代码
|
|