Sub 产生五百万数据() t1 = Timer Sheets(1).UsedRange.ClearContents Application.ScreenUpdating = False For i = 1 To 100000 For j = 1 To 25 d = Rnd() * 1000 Cells(i, j) = d Cells(i, j + 25) = d Next j Next i t2 = Timer Application.ScreenUpdating = True MsgBox t2 - t1 '一百万,15秒。五百万,74秒。70秒。 End Sub Sub 加入字典() Dim d As Object t1 = Timer Set d = CreateObject("scripting.dictionary") For i = 1 To 100000 For j = 1 To 50 d1 = Cells(i, j) If Not d.exists(d1) Then d.Add d1, "" End If Next j Next i t2 = Timer MsgBox t2 - t1 '369秒 MsgBox d.Count '2495749 。 End Sub