Hello
I am trying to design a simple excel database that tracks audit findings and actions and includes automated email updates on 28 days and 7 days periods. I am a VBA novice (ish) and have so far been able to use various forums to paste and amend the following macro, which works perfectly for the task (continue to bottom to see what the issue is):
As you can see, at "28 days" the macro picks up and creates an auto email ready to send as a reminder. What I need to do now (after the email is created) is replace the "28 Days" within the worksheet for something like "28 Days*" to identify that a reminder has already been sent and stop the macro from creating another reminder email in future.
I wait in anticipation for all you VBA geniuses to help find a solution
P.S. the offset for the "28 Days" identifier would be +5 (columns).
I am trying to design a simple excel database that tracks audit findings and actions and includes automated email updates on 28 days and 7 days periods. I am a VBA novice (ish) and have so far been able to use various forums to paste and amend the following macro, which works perfectly for the task (continue to bottom to see what the issue is):
Code:
Sub Notify()
Dim WS As Worksheet, Rng As Range, c As Range
Dim OutApp As Object, OutMail As Object
Dim Msg As String, Addr As String, FName As String, i As Long
Dim NotificationNecessary As Boolean
Set OutApp = CreateObject("Outlook.Application")
Set WS = ThisWorkbook.Sheets("Sheet1")
Set Rng = WS.Range("F6", WS.Range("F" & Rows.Count).End(xlUp))
For Each c In Rng
NotificationNecessary = False
FName = Left(c, InStr(1, c, " ") - 1)
Msg = "Dear " & FName & Chr(13) & Chr(13)
Msg = Msg & "The following action from the " & c.Offset(, -3) & " audit is due for completion by " & c.Offset(, 3) & ":" & Chr(13)
Msg = Msg & " - Audit Finding: " & c.Offset(, 6) & Chr(13)
Msg = Msg & " - Agreed Action: " & c.Offset(, 8) & Chr(13)
Msg = Msg & " - Auditor: " & c.Offset(, -5) & Chr(13)
For i = 11 To 11
If WS.Cells(c.Row, i) = "28 Days" Then
NotificationNecessary = True
End If
Next
If NotificationNecessary Then
Msg = Msg & Chr(13) & "Please review the above action for completeness and provide an update to the Auditor on or before the due date." & Chr(13)
Msg = Msg & Chr(13) & "Regards" & Chr(13)
Msg = Msg & Chr(13) & "Internal Audit"
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = c.Offset(, 1)
.CC = ""
.BCC = ""
.Subject = "Reminder: Audit action due for completion within 28 days"
.Body = Msg
.Display
End With
Set OutMail = Nothing
End If
Next
End Sub
As you can see, at "28 days" the macro picks up and creates an auto email ready to send as a reminder. What I need to do now (after the email is created) is replace the "28 Days" within the worksheet for something like "28 Days*" to identify that a reminder has already been sent and stop the macro from creating another reminder email in future.
I wait in anticipation for all you VBA geniuses to help find a solution
P.S. the offset for the "28 Days" identifier would be +5 (columns).