Remplace module1 en VBA par ceci :
Le programme indiquera quelle feuille n'existe pas le cas échéant.
Option Explicit
Sub alerter()
Dim messagerie As Object
Dim email As Object
Dim cel As Range
Dim txt As String
Dim ws As Worksheet
Set messagerie = CreateObject("Outlook.Application")
Dim i, j, qui
With Sheets("GESTIONNAIRES")
For i = 2 To .Cells(Application.Rows.Count, 1).End(xlUp).Row
qui = .Cells(i, 1)
txt = "<table>"
For j = 2 To .Cells(i, 1).End(xlToRight).Column
If FeuilleExiste(.Cells(i, j).Value) = False Then
MsgBox "La feuille """ & .Cells(i, j).Value & """ n'existe pas !"
Exit Sub
End If
Set ws = Sheets(.Cells(i, j).Value)
ws.Select
txt = txt & "<tr><td><b>" & ws.Name & "</b></td></tr>"
Set cel = Range("A14")
txt = txt & "<tr><td>" & _
cel.Offset(0, 0) & "</td><td>" & _
cel.Offset(0, 1) & "</td><td>" & _
cel.Offset(0, 3) & "</td><td>" & _
cel.Offset(0, 9) & "</td><td>" & _
cel.Offset(0, 15) & "</td><td>" & _
cel.Offset(0, 20) & "</td><td>" & _
cel.Offset(0, 27) & "</td><td>" & _
"</td></tr>"
For Each cel In Range("A15:A" & Range("A14").End(xlDown).Row)
If cel.Offset(0, 27) < Now + 15 And cel.Offset(0, 27) > Now Then
cel.Offset(0, 34) = Now
txt = txt & "<tr><td>" & _
cel.Offset(0, 0) & "</td><td>" & _
cel.Offset(0, 1) & "</td><td>" & _
cel.Offset(0, 3) & "</td><td>" & _
cel.Offset(0, 9) & "</td><td>" & _
cel.Offset(0, 15) & "</td><td>" & _
cel.Offset(0, 20) & "</td><td>" & _
cel.Offset(0, 27) & "</td><td>" & _
"</td></tr>"
End If
Next cel
Next
txt = txt & "</table>"
'Debug.Print txt
Set email = messagerie.CreateItem(0)
With email
.To = qui
.Subject = "Alerte sur fin de contrat"
.htmlbody = txt & .htmlbody
.display ' à remplacer par .send si ok
End With
Set email = Nothing
Next
End With
Set messagerie = Nothing
End Sub
Sub auto_open()
alerter
End Sub
Function FeuilleExiste(sNomFeuille As String) As Boolean
On Error GoTo Err_FeuilleExiste
FeuilleExiste = False
FeuilleExiste = Not ActiveWorkbook.Worksheets(sNomFeuille) Is Nothing
Err_FeuilleExiste:
End Function