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
| Sub tcd_vba()
Dim c As Integer, i As Integer, j As Integer
Dim deja As Boolean
c = 7
For i = 2 To Range("A1000").End(xlUp).Row 'lecture des lignes
If Cells(1, c - 1) <> Cells(i, 1) Then
Cells(1, c) = Cells(i, 1) ' choix de date si non doublon
c = c + 1
End If
Cells(2, 6) = Cells(2, 2) ' Premier élément equipe
deja = False
fin = Range("F1000").End(xlUp).Row
j = 2
While Not deja And j <= fin ' recherche doublon equipe
deja = Cells(j, 6) = Cells(i, 2)
j = j + 1
Wend
If Not deja Then
Cells(fin + 1, 6) = Cells(i, 2) 'nouvelle equipe
Cells(j, c - 1) = Cells(j, c - 1) + Cells(i, 3) 'prime '
Else
Cells(j - 1, c - 1) = Cells(j - 1, c - 1) + Cells(i, 3) 'prime en plus '
End If
Next i
End Sub |
Partager