Hé hé, problème d'initialisation des messages ...
Merci Steelson mais mon problème ce n'est pas ça je pense que je suis mal exprimé.
Tu t'étais très bien exprimé, mais la macro était vicieuse car le message s'initialise une fois et reste gravé même s'il n'y a plus d'événements, bref c'était un peu le bazar mais c'était piégeant !
Option Explicit
Dim f As Worksheet
Private Sub Workbook_Open()
Set f = Feuil1
Dim i&, mess1$, mess2$, mess3$, mess4$, flag&
mess1 = "": mess2 = "": flag = 0
mess4 = "CONVENTIONS DEVANT ÊTRE RENOUVELEES :" & Chr(10)
mess3 = "CONVENTIONS ARRIVEES A ECHEANCES :" & Chr(10)
With f
For i = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If .Cells(i, 1) <> "" Then
If Date >= .Cells(i, 5) And .Cells(i, 5) < DateSerial(Year(Date), Month(Date) + 2, Day(Date)) Then
mess2 = mess2 & .Cells(i, 1) & " ''" & .Cells(i, 2) & Chr(10)
ElseIf .Cells(i, 5) > Date And .Cells(i, 5) <= DateSerial(Year(Date), Month(Date) + 3, Day(Date)) Then
mess1 = mess1 & .Cells(i, 1) & " ''" & .Cells(i, 2) & Chr(10)
End If
flag = 1
End If
Next i
If flag = 1 Then
MsgBox "ATTENTION ! " & Chr(10) & Chr(10) & mess4 & IIf(mess1 = "", "RAS" & Chr(10), mess1) & Chr(10) & mess3 & IIf(mess2 = "", "RAS" & Chr(10), mess2), 16
End If
End With
End Sub