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
|
Sub sstoto()
Dim PAT As Object
Set PAT = Sheets("Plan appro total")
Dim codearticle
derniereligne = PAT.Range("A3").End(xlDown).Row
z = 4
For z = 4 To 50000 Step 1
codearticle = PAT.Cells(z, 2)
If codearticle <> PAT.Cells(z + 1, 2) Then
lignesstoto = z + 1
ptdepart = z - WorksheetFunction.CountIf(PAT.Columns("B:B"), codearticle)
PAT.Rows("" & lignesstoto & "").Insert Shift:=xlDown
PAT.Cells(lignesstoto, 2) = "Ss-Tt du code : " & codearticle
PAT.Cells(lignesstoto, 3) = PAT.Cells(z, 3)
PAT.Cells(lignesstoto, 4) = WorksheetFunction.SumIf(PAT.Columns("B:B"), codearticle, PAT.Columns("D:D"))
PAT.Cells(lignesstoto, 7) = PAT.Cells(z, 7)
PAT.Cells(lignesstoto, 8) = PAT.Cells(z, 8)
PAT.Cells(lignesstoto, 10) = PAT.Cells(z, 10)
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").WrapText = True
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Font.FontStyle = "Gras"
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Font.ColorIndex = 41
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Borders(xlEdgeTop).LineStyle = xlContinuous
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Borders(xlEdgeTop).Weight = xlThin
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Borders(xlEdgeBottom).LineStyle = xlContinuous
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Borders(xlEdgeBottom).Weight = xlMedium
PAT.Range("A" & lignesstoto & ":J" & lignesstoto & "").Interior.ColorIndex = 24
'recherhe si le produit est en rupture et renseigne la ligne ss total si c'est le cas
For x = ptdepart To z Step 1
If PAT.Cells(x, 9) = "1 ère Rupture" Then
PAT.Cells(lignesstoto, 9) = "Rupture le " & PAT.Cells(x, 1)
End If
Next
z = z + 1
Else
'condition pour sortir de la boucle lorsqu'il n'y a plus de valeur
If PAT.Cells(z, 1) = "" Then
Exit For
End If
End If
Next
End Sub |
Partager