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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
Sub Maj_Mouvements_Stock()
Dim I As Integer, J As Integer, DerLig_Mvts As Integer, DerLig_Pmb As Integer, TitreMvts As Integer, TitrePmb As Integer
Dim dt_jour As Date
Dim Plage_Mvts As Range, Plage_Entrees As Range
Dim Continuer As Boolean
Dim HeureDebut, HeureFin, TempsTotal
HeureDebut = Timer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
dt_jour = Format(Now(), "dd-mm-yyyy")
With Sheets("MVTS")
TitreMvts = 11
DerLig_Mvts = .Cells(.Rows.Count, "C").End(xlUp).Row
Set Plage_Mvts = .Range(.Cells(TitreMvts, "C"), .Cells(DerLig_Mvts, "C"))
Plage_Mvts.Offset(0, 14 - 3).Interior.ColorIndex = xlNone
DerLig_Mvts = DerLig_Mvts + 1
End With
With Sheets("PMB")
TitrePmb = 11
DerLig_Pmb = .Cells(.Rows.Count, "C").End(xlUp).Row
Set Plage_Entrees = .Range(.Cells(TitrePmb, "C"), .Cells(DerLig_Pmb, "C"))
End With
For J = 1 To Plage_Entrees.Count
Continuer = True
For I = 1 To Plage_Mvts.Count
If Plage_Mvts(I) & Plage_Mvts(I).Offset(0, 2) = Plage_Entrees(J) & Plage_Entrees(J).Offset(0, 9) Then
Continuer = False
Plage_Mvts(I).Offset(0, 2) = Plage_Entrees(J).Offset(0, 12 - 3)
Plage_Mvts(I).Offset(0, 3) = Plage_Entrees(J).Offset(0, 13 - 3)
With Plage_Mvts(I).Offset(0, 4)
.Value = Plage_Entrees(J).Offset(0, 14 - 3)
.Interior.Color = RGB(255, 255, 0) ' La quantité apparaît en jaune
End With
End If
Next I
If Continuer = True Then
With Sheets("Mvts")
.Cells(DerLig_Mvts, "A") = "C1"
.Cells(DerLig_Mvts, "B") = dt_jour
.Cells(DerLig_Mvts, "C") = Plage_Entrees(J)
.Cells(DerLig_Mvts, "D").Value = Plage_Entrees(J).Offset(0, 4 - 3) ' Description
.Cells(DerLig_Mvts, "E") = Plage_Entrees(J).Offset(0, 12 - 3) ' Réception
.Cells(DerLig_Mvts, "F").Value = Plage_Entrees(J).Offset(0, 13 - 3) ' Unité
.Cells(DerLig_Mvts, "G").Value = Plage_Entrees(J).Offset(0, 14 - 3) ' Nb pièces
DerLig_Mvts = DerLig_Mvts + 1
End With
End If
Next J
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
HeureFin = Timer
TempsTotal = HeureFin - HeureDebut
MsgBox "Temps total du traitement : " & Round(TempsTotal, 0) & " seconde(s)"
Set Plage_Mvts = Nothing: Set Plage_Entrees = Nothing
End Sub |
Partager