i have an email set up once a check number is filled in see code below
this works well if all the fields are filled in.
is there a way to do an if statement
if Cells(Target.Row, "AB").Value <> blank then an entirely different email needs to be sent, that means override the previous send email based on column 17
Private Sub Macro2(ByVal Target As Range)
If Target.Column = 17 And Target.Cells.Count = 1 Then
If Target.Value <> "" Then
result = MsgBox("pressing OK will send email to notify", vbOKCancel + vbExclamation, "Missing Approval")
If result = vbCancel Then SaveUI = True
If result = vbOK Then
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
On Error Resume Next
newmsg.Recipients.Add (Cells(Target.Row, "Z").Value) ' Add Recipients
newmsg.Recipients.Add (Cells(Target.Row, "AA").Value)
newmsg.Subject = Cells(Target.Row, "B").Value & " Reimbursement" ' Add Subject
newmsg.Body = "This is to inform you that payment has been processed " & _
"on behalf of " & Cells(Target.Row, "B").Value & "." & vbCrLf & "" & _
"Check # " & Cells(Target.Row, "P").Value & " was issued " & " for the amount of " & "$" & Cells(Target.Row, "Q").Value & _
" for services in the month of " & Cells(Target.Row, "C").Value & " for " & Cells(Target.Row, "F").Value & Cells(Target.Row, "G").Value & ", " & "(" & "billed amount " & "$" & Cells(Target.Row, "K").Value & ")." & vbCrLf & "" & _
"(If Check amount is greater than billed amount, this check contains multiple receipts and reimbursement requests.)"
newmsg.Send 'Send Email
newmsg.PrintOut
End If
End If
End If
End Sub
this works well if all the fields are filled in.
is there a way to do an if statement
if Cells(Target.Row, "AB").Value <> blank then an entirely different email needs to be sent, that means override the previous send email based on column 17
Private Sub Macro2(ByVal Target As Range)
If Target.Column = 17 And Target.Cells.Count = 1 Then
If Target.Value <> "" Then
result = MsgBox("pressing OK will send email to notify", vbOKCancel + vbExclamation, "Missing Approval")
If result = vbCancel Then SaveUI = True
If result = vbOK Then
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
On Error Resume Next
newmsg.Recipients.Add (Cells(Target.Row, "Z").Value) ' Add Recipients
newmsg.Recipients.Add (Cells(Target.Row, "AA").Value)
newmsg.Subject = Cells(Target.Row, "B").Value & " Reimbursement" ' Add Subject
newmsg.Body = "This is to inform you that payment has been processed " & _
"on behalf of " & Cells(Target.Row, "B").Value & "." & vbCrLf & "" & _
"Check # " & Cells(Target.Row, "P").Value & " was issued " & " for the amount of " & "$" & Cells(Target.Row, "Q").Value & _
" for services in the month of " & Cells(Target.Row, "C").Value & " for " & Cells(Target.Row, "F").Value & Cells(Target.Row, "G").Value & ", " & "(" & "billed amount " & "$" & Cells(Target.Row, "K").Value & ")." & vbCrLf & "" & _
"(If Check amount is greater than billed amount, this check contains multiple receipts and reimbursement requests.)"
newmsg.Send 'Send Email
newmsg.PrintOut
End If
End If
End If
End Sub