1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Sub essai_de_rapidité_v2()
Dim MesTours()
MesTours = Array(Rows.Count, 1)
For Each tour In MesTours
Set cel = Nothing
Set cellule = Nothing
Range("a" & MesTours(1)) = "": Range("a" & MesTours(0)) = ""
Range("a" & tour) = "toto"
With Worksheets(1).Range("a1:a" & Rows.Count)
avant = Timer
'1ere temps
For Each cel In .Range("a1:a" & Rows.Count)
If cel = "toto" Then temps1 = Timer - avant: Exit For
Next
'2eme temps
avant2 = Timer
Set cellule = .Range("a1:a" & Rows.Count).find("toto")
If Not cellule Is Nothing Then temps2 = Timer - avant2
avant3 = Timer
'3ème temps
Dim montablo()
montablo = .Value
For i = 1 To UBound(montablo)
If montablo(i, 1) = "toto" Then
temps3 = Timer - avant3
Exit For
End If
Next i
avant4 = Timer
Set dico = CreateObject("Scripting.Dictionary")
dico = Range("a1:a" & Rows.Count).Value
For Each elem In dico
e = e + 1
If elem = "toto" Then temps4 = Timer - avant4
Next
MsgBox "methode for each dans dictionnaire = " & temps4 & " position= A" & e & vbCrLf & _
"methode for each = " & temps1 & " position=" & cel.Row & vbCrLf & _
"methode avec find = " & temps2 & " position=" & cellule.Row & vbCrLf _
& "methode for each tablo = " & temps3 & " position=" & i, , "Position = A" & tour
End With
Next tour
End Sub |