depending on columns filled in choose correct email to send

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
405
Office Version
  1. 365
Platform
  1. Windows
hi
i have a working vba that sends an email when a check number is filed in in column Q.
i have been playing around with the code but cant get it correct. i think a need an if and else but dont quite know where to put it.
the cation is that column Q is filled in that is the target
what i'd like to add is send the email if column AB is blank
but if column AB is NOT blank then a different email
where and how would i add this

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
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Watch MrExcel Video

Forum statistics

Threads
1,129,493
Messages
5,636,641
Members
416,932
Latest member
mm07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top