Sub GetGidPacTxT()
Dim UM As Worksheet, InitRowUM As Long, VA, L, x As Long, Txt$, y As Integer, Pos As Integer, PAC$, T!
Dim FindPAC As Integer, Deb As Integer, S, V, gidValue$, gidPart$, P, sumResult As Double
SupprimerDonneesUM
T = Timer
VA = ThisWorkbook.Sheets("BD").ListObjects(1).DataBodyRange.Value
Set UM = ThisWorkbook.Sheets("UM")
InitRowUM = 10
Application.ScreenUpdating = False
L = GetBordereau(CStr(UM.Range("D3").Value)) 'Cherche les lignes correspondante au borderau
If L <> "" Then
L = Split(L, "|")
For x = LBound(L) To UBound(L)
Txt = VA(L(x), 2): FindPAC = InStr(Txt, "+PAC+")
If FindPAC = 0 Then
ReDim V(1 To 1, 1 To 9)
V(1, 1) = VA(L(x), 3): V(1, 2) = VA(L(x), 1): V(1, 3) = VA(L(x), 5): V(1, 4) = VA(L(x), 6): V(1, 5) = VA(L(x), 7)
V(1, 6) = VA(L(x), 8): V(1, 7) = VA(L(x), 9): V(1, 8) = VA(L(x), 10): V(1, 9) = VA(L(x), 11)
UM.Cells(InitRowUM, 1).Resize(UBound(V), UBound(V, 2)).Value = V
InitRowUM = InitRowUM + 1
Else
Deb = InStrRev(Txt, "GID++", FindPAC)
S = Mid(Txt, Deb): S = Split(S, "GID++")
ReDim V(1 To UBound(S), 1 To 15)
For y = 1 To UBound(S)
Pos = InStr(S(y), ":"): gidValue = Mid(S(y), 1, Pos - 1): gidPart = Mid(S(y), Pos + 1, 2)
Pos = InStr(S(y), "+PAC+") + 5: PAC = Mid(S(y), Pos): P = Split(PAC, ":")
V(y, 1) = VA(L(x), 3): V(y, 2) = VA(L(x), 1): V(y, 3) = VA(L(x), 5): V(y, 4) = VA(L(x), 6): V(y, 5) = VA(L(x), 7)
V(y, 6) = VA(L(x), 8): V(y, 7) = VA(L(x), 9): V(y, 8) = VA(L(x), 10): V(y, 9) = VA(L(x), 11)
V(y, 11) = P(0): V(y, 12) = P(1): V(y, 13) = P(2): V(y, 14) = gidValue: V(y, 15) = gidPart
sumResult = sumResult + Evaluate(P(0) & " * " & P(1) & " * " & P(2) & " * " & gidValue)
Next
For y = 1 To UBound(S): V(y, 10) = sumResult: Next
UM.Cells(InitRowUM, 1).Resize(UBound(V), UBound(V, 2)).Value = V
InitRowUM = InitRowUM + UBound(V)
sumResult = 0
End If
Next
Bordures
Else
MsgBox "Borderau non trouvé"
End If
Application.ScreenUpdating = True
MsgBox "Processus: " & Format$(Timer - T, "0.0000s")
End Sub