Sub DictionaryPerformanceDemo()Dim dict As Object Set dict = CreateObject("Scripting.Dictionary")' 添加大量数据Dim startTime As DoublestartTime = Timer' 使用字典快速添加和查找 For i = 1 To 10000 dict("Key_" & i) = "Value_" & i Next iDebug.Print "添加10000个元素耗时: " & _Format(Timer - startTime, "0.000") & "秒"' 快速查找测试startTime = TimerDim result As Stringresult = dict("Key_5000")Debug.Print "查找元素耗时: " & _Format(Timer - startTime, "0.000000") & "秒"' 与数组查找对比Dim arrKeys(1 To 10000) As StringDim arrValues(1 To 10000) As StringFor i = 1 To 10000 arrKeys(i) = "Key_" & i arrValues(i) = "Value_" & iNext istartTime = TimerFor i = 1 To 10000 If arrKeys(i) = "Key_5000" Then result = arrValues(i) Exit For End IfNext iDebug.Print "数组遍历查找耗时: " & _Format(Timer - startTime, "0.000000") & "秒"End Sub