Dim F As Worksheet, CelModel As Range 'mémorise les variables
Private Sub Workbook_Open()
Dim c As Range, tablo, i&, flag As Boolean, x$, y$
Set F = Sheets("Message") 'feuille auxiliaire
Set CelModel = F.[H12] 'dont la ligne est masquée
CelModel(2).Resize(F.Rows.Count - CelModel.Row).EntireRow.Delete 'RAZ
Set c = CelModel(2)
F.Visible = xlSheetHidden 'xlSheetVeryHidden
tablo = Sheets("Sommaire IPP").[A5].CurrentRegion.Resize(, 17) 'matrice, plus rapide
For i = 1 To UBound(tablo)
If IsDate(tablo(i, 6)) And UCase(tablo(i, 17)) <> "OK" Then
If Date >= tablo(i, 6) Then
flag = True
CelModel.MergeArea.Copy c
x = tablo(i, 1): y = "IPP " & tablo(i, 2)
c.Replace "xxx", x, xlPart
c.Replace "yyy", y
c.Replace "zzz", Format(tablo(i, 6), "dd/mm/yyyy")
c.Characters(Len(x) + 2, Len(y)).Font.Color = vbRed 'police rouge
Set c = c(2) 'incrémentation
End If
End If
Next
If flag Then Application.OnTime 1, "ThisWorkbook.Affiche" 'exécution différée
End Sub
Sub Affiche()
Dim duree#, t#
duree = 10 'temporisation en secondes, à adapter
Application.ScreenUpdating = False
F.Visible = xlSheetVisible
Application.Goto F.[A1] 'cadrage
CelModel(-1).Select
Application.ScreenUpdating = True
t = Timer + duree
While Timer < t And t < 86400: DoEvents: Wend
F.Visible = xlSheetHidden 'xlSheetVeryHidden
End Sub