Sub test()
Dim i&, x&
'mise en gras des colonnes
Range("D:D,M:O,Q:T").Font.Bold = True
'couleur suivant les caractères
For i = 2 To Range("A65536").End(xlUp).Row
If Cells(i, 4).Value = "S" Then Cells(i, 4).Font.Color = vbRed
If Cells(i, 19).Value = "UPAID" Then Cells(i, 19).Font.Color = vbRed
If Cells(i, 20).Value = "X - DONE" Then Cells(i, 20).Font.Color = vbRed
If Cells(i, 20).Value = "X-MTCH-MACH" Then Cells(i, 20).Font.Color = vbBlue
Next i
'boucle sur les lignes
For i = Range("A65536").End(xlUp).Row To 3 Step -1
If Not Cells(i, 8).Value = Cells(i - 1, 8).Value Then
Rows(i & ":" & i + 3).Insert
End If
Next i
'boucle sur les lignes pour mise en forme
For i = 2 To Range("A65536").End(xlUp).Row + 3
If IsEmpty(Cells(i, 8)) = True And IsEmpty(Cells(i + 1, 8)) = True Then
With Cells(i, 8)
.Value = "Somme " & Cells(i - 1, 8).Value
.Font.Bold = True
.Font.Color = vbBlack
With Cells(i, 10)
.Value = x
.Font.Bold = True
End With
x = 0
End With
With Cells(i + 1, 8)
.Value = "YESTERDAY HOLDING STOCK POSITION"
.Font.Bold = True
.Font.Color = vbBlue
End With
With Cells(i + 2, 8)
.Value = "TODAY HOLDING STOCK POSITION"
.Font.Bold = True
.Font.Color = vbBlue
With Cells(i + 2, 10)
.Value = Cells(i, 10).Value + Cells(i + 1, 10).Value
.Font.Bold = True
If .Value > 0 Then .Font.Color = vbBlue
If .Value < 0 Then .Font.Color = vbRed
End With
End With
Else
If Not Cells(i, 9).Value = "" Then x = x + Cells(i, 10).Value
End If
Next i
With Range("F65536").End(xlUp)(7)
.Value = "Somme " & Range("F65536").End(xlUp).Value
.Font.Bold = True
End With
For i = 2 To Range("A65536").End(xlUp).Row
x = x + Cells(i, 11).Value
Next i
With Range("F65536").End(xlUp).Offset(0, 5)
.Value = x
.Font.Bold = True
.NumberFormat = "#,##0.00 _€"
End With
With Cells
.Interior.ColorIndex = 2
.HorizontalAlignment = xlCenter
.EntireColumn.AutoFit
End With
Rows("2:2").Insert Shift:=xlDown
Rows("2:2").RowHeight = 31.5
With Range("A1:" & Range("IV1").End(xlToLeft).Address(0, 0))
.Interior.ColorIndex = 34
.Font.Bold = True
.RowHeight = 44.25
End With
End Sub