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
| Sub grouper()
Application.ScreenUpdating = False
Dim FL2 As Worksheet, i As Integer, j As Integer, h As String, FromLigne As Integer, ToLigne As Integer
Set FL2 = Sheets("Recap")
DerLig = FL2.Range("B" & FL2.Rows.Count).End(xlUp).Row
Range("A9:A" & DerLig).ClearContents
Range("A9:A" & DerLig).FormulaR1C1 = "=RC[1]&""-""&RC[2]&""-""&RC[3]&""-""&RC[4]"
Range("A9:A" & DerLig).Value = Range("A9:A" & DerLig).Value
For i = 9 To DerLig
Valeur = Cells(i, "A")
If Valeur = "ZZ" Then GoTo Suivant
With FL2.Range("A" & i & ":A" & DerLig)
Set x = .Find(Valeur, LookIn:=xlValues)
If x.Row = i Then GoTo Suivant
If Not x Is Nothing Then
PosDep = x.Address
Do
For c = 19 To 44
If Cells(x.Row, c) <> "" Then Cells(i, c) = Cells(i, c) & Chr(10) & Cells(x.Row, c)
Next c
Cells(x.Row, "A") = "ZZ"
Set x = .FindNext(x)
Loop While Not x Is Nothing And x.Address <> "$A$" & i
End If
End With
Suivant:
Next i
For i = DerLig To 9 Step -1
If Cells(i, "A") = "ZZ" Then Cells(i, "A").EntireRow.Delete
Next i
Range("A9:A" & DerLig).ClearContents
End Sub |
Partager