Accélérer mon code avec collections ou dictionnaire VBA Excel

Bonjour
Voici mon code qui extraire une date d'une chaine de caractère
le code fonctionne très bien mais le problème que ma plage contient beaucoup de lignes (plus de 400000 lignes).

Option Explicit
Sub test()
Dim Derlig As Long
Dim i As Long

Derlig = Sheets("Grand Livre").Cells(Application.Rows.Count, 1).End(xlUp).Row

For i = 3 To Derlig

        If Left(Range("F" & i), 21) = "Piece Encaissement / " Then
            Range("K" & i).Value = Format(Left(Right(Range("F" & i), 12), 10), "mm/dd/yyyy")
        End If
        If Left(Range("F" & i), 21) = "PIECE Synthese GTR-SI" Then
            Range("K" & i).Value = Format(Mid(Range("F" & i), 44, 10), "mm/dd/yyyy")
        End If

        If Left(Range("F" & i), 21) = "Piece journée encaiss" Then
            Range("K" & i).Value = CDate(Replace(Right(Range("F" & i), 10), ".", "/"))
        End If

Next i

End Sub

je souhaite augmenter et améliorer le temps d'exécution
j'ai lu que collections ou dictionnaire ou les tableau augmenter et améliorer le temps d'exécution mais je ne sais pas les utiliser
svp aidez moi.

Salut iliess,

à tester car, à l'aveugle...

Private Sub Test()
'
Dim tTab,i&
'
With Worksheets("Grand Livre")
    tTab = .Range("F3:K" & .Range("A" & Rows.Count).End(xlUp).Row).Value
    For i = 1 To UBound(tTab, 1)
        If Left(tTab(i, 1), 21) = "Piece Encaissement / " Then _
            tTab(i, 6) = Format(Left(Right(tTab(i, 1), 12), 10), "mm/dd/yyyy")
        If Left(tTab(i, 1), 21) = "PIECE Synthese GTR-SI" Then _
            tTab(i, 6) = Format(Mid(tTab(i, 1), 44, 10), "mm/dd/yyyy")
        If Left(tTab(i, 1), 21) = "Piece journée encaiss" Then _
            tTab(i, 6) = CDate(Replace(Right(tTab(i, 1), 10), ".", "/"))
    Next
    .Range("F3").Resize(UBound(tTab, 1), 6).FormulaLocal = tTab
End With
'
End Sub


A+

merci beaucoup Mr ça marche très bien

Rechercher des sujets similaires à "accelerer mon code collections dictionnaire vba"