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 44 45 46
| Sub Tableau()
Dim Plage As Range, C As Range, Dico As Object, Ligne As Long, Col As Integer
With Sheets("les colonnes")
Set Plage = .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp))
.[I:I].ClearContents
.[B:B].Copy .[I1]
.[I:I].Sort .[I1], xlAscending, Header:=xlYes
Set Dico = CreateObject("Scripting.Dictionary")
.[I:I].Copy .[B1]
.[I:I].ClearContents
i = -2
For Each C In Plage.Offset(, 1)
If Not Dico.exists(C.Value) Then
Dico.Add C.Value, C.Value
End If
Next C
End With
With Sheets("Résultat")
.[A2] = "praticien"
For Each Item In Dico.items
i = i + 4
.Cells(1, i).Resize(, 4).Merge
.Cells(1, i) = Format(Item, "dddd dd mmmm yyyy")
.Cells(2, i) = "_M"
.Cells(2, i + 1) = "AM"
.Cells(2, i + 2) = "N1"
.Cells(2, i + 3) = "N2"
Next Item
Dico.RemoveAll
For Each C In Plage
If Not Dico.exists(C.Value) Then
Dico.Add C.Value, C.Value
End If
Next C
For Each Item In Dico.items
.[A60000].End(xlUp).Offset(1) = Item
Next Item
.Columns(1).AutoFit
For Each C In Plage
Col = Application.Match(Format(C.Offset(, 1), "dddd dd mmmm yyyy"), .[1:1], 0)
Col = Col + Evaluate("Match(" & C.Offset(, 2).Address & ",{""_M"",""AM"",""N1"",""N2""},0)") - 1
Ligne = Application.Match(C.Value, .[A:A], 0)
.Cells(Ligne, Col) = C.Offset(, 3)
Next C
End With
End Sub |
Partager