Sub remplir_tableau_rouge1()
Dim f1 As Worksheet, f2 As Worksheet, Mondico As Object, Mondico2 As Object, Mondico3 As Object, Mondico4 As Object, _
Plage As Range, Plage2 As Range, DerLigne&, i&, j&, k&, c As Range, compteur&, Col, Tabl2, Tabl3, Tabl4, Tabl5
Set Mondico = CreateObject("Scripting.Dictionary")
Set Mondico2 = CreateObject("Scripting.Dictionary")
Set Mondico3 = CreateObject("Scripting.Dictionary")
Set Mondico4 = CreateObject("Scripting.Dictionary")
Set f1 = Sheets("bleue")
Set f2 = Sheets("rouge")
'-----------bornes
'------------procedure
With f1
DerLigne = .Range("C" & Rows.Count).End(xlUp).Row
Col = .Range(.Cells(9, 10), .Cells(9, 13)).Value
Set Plage = .Range(.Cells(10, 10), .Cells(DerLigne, 13))
For i = 1 To Plage.Rows.Count
If Not Mondico.exists(Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4)) Then
Mondico.Add Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4), 1
compteur = compteur + 1
Dim tabl()
ReDim Preserve tabl(1 To Plage.Columns.Count, Plage.Rows.Count)
For j = 1 To Plage.Columns.Count: tabl(j, compteur - 1) = Plage(i, j): Next j
End If
Next i
For i = 1 To Plage.Rows.Count
Mondico2.Item(Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4)) = _
Mondico2.Item(Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4)) + 1
Next i
Tabl2 = Mondico2.items
Set Plage2 = .Range(.Cells(10, 10), .Cells(DerLigne, 19))
For i = 1 To Plage2.Rows.Count
Mondico3.Item(Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4) & "#" & Plage(i, 10)) = _
Mondico3.Item(Plage(i, 1) & Plage(i, 2) & Plage(i, 3) & Plage(i, 4) & "#" & Plage(i, 10)) + 1
Next i
Tabl3 = Mondico3.keys
Tabl4 = Mondico3.items
For Each c In .Range("S10", .Range("S" & Rows.Count).End(xlUp))
Mondico4(c.Value) = c.Value
Next c
Tabl5 = Mondico4.keys
End With
With f2
.Range("F24").Resize(Plage.Columns.Count, Plage.Rows.Count) = tabl
.Range("E30").Resize(Mondico4.Count) = Application.Transpose(Tabl5)
.Range("E24").Resize(Plage.Columns.Count) = Application.Transpose(Col)
For i = 1 To Mondico4.Count
For k = LBound(tabl) To UBound(Tabl2) + 1
If Right(Tabl3(k - 1), 2) = .Cells(i + 29, 5).Value Then Cells(i + 29, k + 5) = Tabl4(k - 1)
Next k
Next i
End With
End Sub