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
| Sub Test()
Dim Numero_CE As String, Numero_CDE As String, Fournisseur As String
Dim Nombre_Lignes As Long, Nombre_Lignes_BDD As Long
Dim i As Long, j As Long, k As Long
Dim Montant_CDE As Double
Application.ScreenUpdating = False
With Sheets("base de donnée")
Nombre_Lignes_BDD = .Cells(.Rows.Count, 3).End(xlUp).Row
End With
With Sheets("TCD")
Nombre_Lignes = .Cells(.Rows.Count, 16).End(xlUp).Row
For i = 3 To Nombre_Lignes
Application.StatusBar = " Traitement de m'opération " & i & "/" & Nombre_Lignes
Numero_CE = .Cells(i, 16).Value
Numero_CDE = .Cells(i, 17).Value
Fournisseur = .Cells(i, 18).Value
Montant_CDE = Val(Replace(.Cells(i, 19).Value, ",", "."))
With Sheets("base de donnée")
For j = 2 To Nombre_Lignes_BDD
If .Cells(j, 3).Value = Numero_CE And .Cells(j, 6).Value = Fournisseur Then
k = 18
Do Until .Cells(j, k) = ""
k = k + 3
Loop
.Cells(j, k).Value = Numero_CDE
.Cells(j, k + 2).Value = Montant_CDE
Exit For
End If
Next j
End With
Next i
End With
End Sub |
Partager