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
|
While j <> k + k
i = 1
'Tant que la condition ci-dessous est vraie, on boucle
If Cells(j, 1).Value <> "total" And _
Cells(j, 1).Value <> "" And _
Cells(j, 1).Value <> Cells(j - 1, 1).Value Then
For Each cellule In Range(Cells(2, 1), Cells(k + k, 1))
If Cells(j, 1).Value = Cells(j + i, 1).Value Then i = i + 1
Next
Rows(i + j).Insert
Cells(i + j, 1).Value = "total"
Cells(i + j, 1).HorizontalAlignment = xlHAlignLeft ' texte centré à gauche
Cells(i + j, 4).Value = Application.WorksheetFunction.Sum(Range(Cells(i + j - 1, 4), Cells(j, 4))) 'calculer les totaux
x = x + Cells(i + j, 4).Value
Range(Cells(i + j, 4), Cells(i + j, 5)).HorizontalAlignment = xlHAlignRight 'centrer horizontalement
Range(Cells(i + j, 4), Cells(i + j, 5)).Interior.ColorIndex = 30 ' mettre la cellule en bordeau
Range(Cells(i + j, 4), Cells(i + j, 5)).Font.ColorIndex = 2 ' mettre en blanc
Range(Cells(i + j, 1), Cells(i + j, 5)).Select
With Selection
.Font.Bold = True 'mets en gras
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeTop).ColorIndex = 30
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeBottom).ColorIndex = 30
End With
j = j + 1
Else: j = j + 1
End If |
Partager