如果我将一些局部变量声明为Variant而不是特定类型,我似乎得到一个更快的宏:
最初:
Dim aTemplate As Excel.Workbook
Set aTemplate = Excel.Workbooks("blah.xlsx")
改为:
Dim aTemplate As Variant
Set aTemplate = Excel.Workbooks("blah.xlsx")
然后将此变量传递给其他例程,如:
Call someOtherRoutine(aTemplate)
我已经更改了接收器签名:
最初:
Sub someOtherRoutine(ByRef aWorkBk As Object)...
改为:
Sub someOtherRoutine(ByRef aWorkBk As Variant)...
哪种变化给了我性能提升以及为什么?