Hi all,
I have the below code, currently I have hard coded the email to address but I have a list on a "Variables" tab, range J2:K10 (also below) with where the report should go. Rather than updating the code, I was wondering if I could lookup to this list and return the right to person.
Thanks in advance - Karl
'Email report code
Const SCC = "DIRECTORY REMOVED"
'Turn off screen updating
Application.ScreenUpdating = False
'Make a copy of the active sheet and save it to a temporary file
'Selects the SCC sheet
Sheets("SCC").Select
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Set wb = ActiveWorkbook
Application.DisplayAlerts = False
wb.SaveAs SCC
Application.DisplayAlerts = True
'Create and show the outlook mail item
Set oMail = CreateObject("Outlook.Application").CreateItem(0)
With oMail 'Add a recipient
.To = "joe.bloggs@example.com"
.Subject = "SCC Report"
.Body = "Please find attached your report."
.Attachments.Add wb.FullName
.send
I have the below code, currently I have hard coded the email to address but I have a list on a "Variables" tab, range J2:K10 (also below) with where the report should go. Rather than updating the code, I was wondering if I could lookup to this list and return the right to person.
Thanks in advance - Karl
SCC | joe.bloggs1@example.com |
NIR | joe.bloggs2@example.com |
DDR | joe.bloggs3@example.com |
LIT | joe.bloggs4@example.com |
LXT | joe.bloggs5@example.com |
ENF | joe.bloggs6@example.com |
'Email report code
Const SCC = "DIRECTORY REMOVED"
'Turn off screen updating
Application.ScreenUpdating = False
'Make a copy of the active sheet and save it to a temporary file
'Selects the SCC sheet
Sheets("SCC").Select
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Set wb = ActiveWorkbook
Application.DisplayAlerts = False
wb.SaveAs SCC
Application.DisplayAlerts = True
'Create and show the outlook mail item
Set oMail = CreateObject("Outlook.Application").CreateItem(0)
With oMail 'Add a recipient
.To = "joe.bloggs@example.com"
.Subject = "SCC Report"
.Body = "Please find attached your report."
.Attachments.Add wb.FullName
.send