Private Sub Workbook_Open()
Dim LOt As ListObject, DateAlerte As Date, CCPF As Integer, CDCC As Integer, TDon(), TMsg() As String, L&, M&
Set LOt = Feuil1.ListObjects(1)
DateAlerte = Date - Feuil2.[C2].Value
CCPF = LOt.ListColumns("Commande passée au Fournisseur").Index
CDCC = LOt.ListColumns("Date Comm. Client").Index
If LOt.ListRows.Count < 1 Then Exit Sub
TDon = LOt.DataBodyRange.Value
For L = 1 To UBound(TDon, 1)
If TDon(L, CDCC) <= DateAlerte And IsEmpty(TDon(L, CCPF)) Then
M = M + 1: ReDim Preserve TMsg(1 To M)
TMsg(M) = TDon(L, 1) & " " & TDon(L, 2) & " " & TDon(L, 3)
End If
Next L
If M > 0 Then MsgBox "Commandes non passées aux fournisseurs :" _
& vbLf & "— " & Join(TMsg, vbLf), vbExclamation, "Ouverture " & ThisWorkbook.Name
End Sub