Option Explicit
Sub ConsoParJour()
Dim LaDate As Date, Client As String, Données As Collection, SG As SsGr, Trés(1 To 1500, 1 To 4), L As Long
Client = Feuil12.[E1].Value
If Client <> "" Then
Set Données = Gigogne(Feuil10.[B7:H7], 3, 2, 1, 5)
On Error Resume Next: Set SG = Données.Item(Client): On Error GoTo 0
If SG Is Nothing Then MsgBox "Aucune sortie pour """ & Client & """ trouvée.", _
vbCritical, "ConsoParJour": Exit Sub
Set Données = SG.Co
Else
Set Données = Gigogne(Feuil10.[B7:H7], 2, 1, 5)
End If
LaDate = Feuil12.[A1].Value
For Each SG In Données
If SG.ID = LaDate Then Exit For
Next SG
If SG Is Nothing Then MsgBox "Aucune sortie du " & LaDate & " trouvée.", _
vbCritical, "ConsoParJour": Exit Sub
Set SG = SG.ItemSsGr("sortie")
If SG Is Nothing Then MsgBox "Aucune sortie du " & LaDate & " trouvée.", _
vbCritical, "ConsoParJour": Exit Sub
Set Données = SG.Co
For Each SG In Données
L = L + 1
Trés(L, 1) = SG.ID
Trés(L, 2) = SG.Somme(6)
Trés(L, 3) = SG.Co(1)(7)
Trés(L, 4) = Trés(L, 2) * Trés(L, 3)
Next SG
Feuil12.[A5].Resize(1500, 4).Value = Trés
End Sub