Hi, I'm quite new to VBA, but have managed to put together code in a schedule that sends an email to the task owner and co-owner if a task is overdue. The email addresses are stored in the worksheet. It works ok, except that I've clearly not set something up correctly as at the moment the emails are all going to the addresses in F4 and H4 (see below). I just can't work out how I should change this so that it loops through each row and, if column U shows 'Overdue', an email is sent to the address in columns F and H. Can anyone help please? Thanks, Rachel
Sub Send_UK_Overdue()
Dim Mail_Object, Mail_Single As Variant
Dim rng As Range
Dim rngFound As Range
Set rng = Range("U:U")
Set rngFound = rng.Find("Overdue")
nameEmail = Range("F4").Value
ccEmail = Range("H4").Value
If rngFound = rng.Find("Overdue") Then
Email_Subject = "Overdue Task"
Email_Send_From = "EMAIL ADDRESS"
Email_Send_To = nameEmail
Email_Cc = ccEmail
Email_Body = "You have an task overdue by two weeks or more."
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End If
End Sub
Bookmarks