Salut à tous,
Désolé, j'étais sur un autre boulot.
J'ai un petit problème sur ma boucle, où faut-il que je l'a place?
Private Sub Workbook_Open()
Dim xlws As Excel.Worksheet
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim strDestMail$
strDestMail = "Adresses mails destinataires" 'séparer les adresses mails par un ;
Set xlws = ThisWorkbook.Sheets(1)
Dim rColonne as range, C as range
Dim DateAlerte as date
set rColonne=thisworkbook.sheets("LeNomDeLaFeuille").range("D:D") 'si c'est la colonne D à tester
for each C in rColonne
DateAlerte=C + 7 '(si tu veux être averti 7 jours avant la date butoir)
if DateAlerte > Now Then 'si ta date d'alerte n'est pas dépassé
'...le code de l'envoie du message
end if
next C
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.Subject = "Date du contrôle proche"
.Body = "Texte du Message"
.To = strDestMail
.Display
.Send
End With
olApp.Quit
Set olMail = Nothing
Set olApp = Nothing
End If
End Sub