Hi all... I might be being a little dumb here, but I have the following codes that work fine, one for an error message when a certain criteria isn't met, the other sends an email template, populated with certain cell values. I woudl like to combine the two, but am struggling (I'm still a relative novice with VBA so the answer is probably simple).
Private Sub Worksheet_Calculate()
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
If Range("F2").Value > " " Then
strPrompt = "'Name' cell must be populated for feedback email to be sent!" _
& vbNewLine
strTitle = "Attention!"
iRet = MsgBox(strPrompt, vbYes, strTitle)
If iRet = vbYes Then
End If
End If
- - - - -
Sub SendEmail()
'Automatically creates an new email, populated with relevant data from the spreadsheet'
Dim OApp As Object, OMail As Object, signature As String
Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
With OMail
signature = OMail.body
.ReadReceiptRequested = True
.To = Range("F2")
.cc = Range("AC131") & ";" & Range("AC133")
.Importance = 2
.Subject = Range("F2") & "'s" & " " & Range("AC118") & " " & "Call" _
& " " & Range("AB118") & " " & "Coaching Feedback"
.body = "Hi" & " " & Range("P131") & vbNewLine & vbNewLine _
& "Here is the feedback from the call I have assessed for you today..." & vbNewLine & vbNewLine _
& "Date of Call:" & " " & Range("AB6") & vbNewLine _
& "Time of Call:" & " " & Format(Range("AB8"), "hh:mm:ss") & vbNewLine & vbNewLine _
& Range("O63") & vbNewLine & vbNewLine _
& "If you have any questions regarding the above, or would like to discuss anything further, please let me know." & vbNewLine & vbNewLine _
& "Regards," & vbNewLine & vbNewLine _
& Range("W131") & signature
.Display
End With
Set OMail = Nothing
Set OApp = Nothing
End Sub
So if "F2" is blank, error message appears, if it is populated, the email is generated...
Any ideas?
Thanks,
PAS
Bookmarks