I'm looking send to specific email addresses by looking for header "Fund Email" and then sending email to first cell beneath matching header. the email address column is not always the same which is why i need it to return the cell beneath (which is where the email address is, eg email header ak1-email address ak2) once it matches.
[Excel file example][1] [1]:
I want to replace range AJ2 in my code with something that can lookup the header (row 1) and insert the email address that corresponds (single cell, row 2). Because like I said above the column might not always be AJ, but the header will always be "fund email".
ActiveWorkbook.SaveAs
"\\na\Forrest\Backup.xlsx"
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Range("AJ2").Value
.CC = ""
.BCC = ""
.Subject = Range("AK2").Value + " -Benefits backup"
.Body = "Attached is the current month's benefit payment backup for
check en route to your fund's office."
.Attachments.Add ActiveWorkbook.FullName
.send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.Close
Thanks!
[Excel file example][1] [1]:
I want to replace range AJ2 in my code with something that can lookup the header (row 1) and insert the email address that corresponds (single cell, row 2). Because like I said above the column might not always be AJ, but the header will always be "fund email".
ActiveWorkbook.SaveAs
"\\na\Forrest\Backup.xlsx"
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Range("AJ2").Value
.CC = ""
.BCC = ""
.Subject = Range("AK2").Value + " -Benefits backup"
.Body = "Attached is the current month's benefit payment backup for
check en route to your fund's office."
.Attachments.Add ActiveWorkbook.FullName
.send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.Close
Thanks!