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
| Sub regroup()
Application.ScreenUpdating = False
Dim w As Worksheet
Dim f2 As Worksheet
Dim Dercol As Long
Set f2 = Sheets("SYNTHESE")
f2.Cells.ClearContents
Dim unique As New Collection
Dim j As Long
Dim i As Long
On Error Resume Next
Set d = CreateObject("Scripting.Dictionary")
For Each w In ThisWorkbook.Worksheets
If w.Name <> "CONSOLIDER" And w.Name <> "SYNTHESE" Then
f2.Cells(1, 1) = w.Cells(1, 1)
f2.Cells(1, 2) = w.Cells(1, 2)
For C = 3 To 8
unique.Add w.Cells(1, C).Value, CStr(w.Cells(1, C).Value)
Next C
End If
TblBD = w.Range("A2:H" & w.Range("H" & Rows.Count).End(xlUp).Row)
For i = 1 To UBound(TblBD)
clé = TblBD(i, 1) & "|" & TblBD(i, 2)
d(clé) = d(clé) & "|" & TblBD(i, 3) & "|" & TblBD(i, 4) & "|" & TblBD(i, 5) & "|" & TblBD(i, 6) & "|" & TblBD(i, 7) & "|" & TblBD(i, 8)
Next i
Next w
f2.Range("A2").Resize(d.Count) = Application.Transpose(d.keys)
f2.Range("C2").Resize(d.Count) = Application.Transpose(d.items)
Application.DisplayAlerts = False
f2.Range("A2").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
f2.Range("C2").Resize(d.Count).TextToColumns Other:=1, OtherChar:="|"
On Error GoTo 0
For j = 1 To unique.Count
f2.Cells(j + 3) = unique(j)
Next j
f2.Activate
f2.Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
C = 3
Application.ScreenUpdating = True
f2.Select
End Sub |
Partager