Automatisation mail à condition
Bonjour à tous,
Je suis débutant en vba et me renseigne depuis peu. Je cherche à réaliser une macro qui envoie un mail à des contacts avec conditions.
Si la personne A est égal et supérieur à 50 ou bien égal et inférieur à 50 alors envoie d'un mail.
Ma colonne a checké est la G à partir de la ligne 24 jusqu'à la ligne 279.
Si la personne remplie donc la condition, on cherche le mail dans une feuille différente nommée ici "Sheet1" en colonne B (à partir de la B3 jusqu'en bas). Maintenant il faut réussir à pouvoir sélectionner les bons contacts par rapport à la condition mais je ne sais encore comment procéder.
Je sais que tout n'est pas bon mais j'ai réalisé une draft grâce à ce forum, pouvez-vous m'indiquer les rectifications à faire pour que je puisse lancer la macro ?
Merci encore
Sub aargh()
With Sheets("BSfin") ' à adapter
dl = .Cells(Rows.Count, "G").End(xlUp).Row
Set ol = CreateObject("Outlook.Application")
For i = 1 To dl
If Range("G24:G279") >= "50" Or If Range ("G24:G279") <= "-50" Then
Set olm = ol.CreateItem(0)
With olm
.To = "mail; mail; mail; ..."
.CC = "mail; mail; ..."
.Subject = "Test mail automatique"
.body = "à complétér"
.Display
.Save
End With
.Cells(i, "G") = ""
.Cells(i, "G") = "50"
End If
Next i
End With
End Subbonjour,
une proposition (non testée)
Sub aargh()
With Sheets("BSfin") ' à adapter
dl = .Cells(Rows.Count, "G").End(xlUp).Row
Set ol = CreateObject("Outlook.Application")
For i = 1 To dl
If .cells(i,"G") >= 50 Or .cells(i,"G") <= -50 Then
Set olm = ol.CreateItem(0)
With olm
.To = "mail; mail; mail; ..."
.CC = "mail; mail; ..."
.Subject = "Test mail automatique"
.body = "à complétér"
.Display
.Save
End With
.Cells(i, "G") = ""
.Cells(i, "G") = 50
End If
Next i
End With
End Sub