You can put the names into an array, then loop through that:
Private Sub Workbook_Open()
Dim i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, strbody As String
dim arrInits as variant
dim intAddress as integer
For i = 6 To Sheets("FMEA").Range("B65536").End(xlUp).Row
If Sheets("FMEA").Cells(i, 13).Value = (Date) Then
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
if instr(1,Sheets("FMEA").Cells(i, 12).Value,",") > 0 then
arrinits = split(Sheets("FMEA").Cells(i, 12).Value, ",")
else
redim arrinits(1 to 1)
arrinits = Sheets("FMEA").Cells(i, 12).Value
endif
for intaddress = lbound(arrinits) to ubound(arrinits)
on error resume next
strto = application.worksheetfunction.vlookup(arrinits(intaddress), _
thisworkbook.names("NameMap").referstorange,2,false)
if err <> 0 then
strto = ""
endif
on error goto 0
if strto > "" _
and strto <> "#N/A" then
'strto = Sheets("FMEA").Cells(i, 12).Value
'strcc = Sheets("FMEA").Cells(i, 13).Value & _
"; " & Sheets("FMEA").Cells(i, 5).Value
strbcc = ""
strsub = "Contract Expiry Notice"
strbody = "Hi there" & vbNewLine & vbNewLine & _
"Your contract, " & Sheets("FMEA").Cells(i, 11).Value & _
", is due to expire on " & Sheets("FMEA").Cells(i, 13).Value & _
". Please contact us at your earliest convenience." & _
vbCrLf & vbCrLf & "Thank you."
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
.Send
End With
endif
next intaddress
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
End Sub
You will need to define a Named Range "NameMap" that contains a list of your initials and e-mail addresses.
Bookmarks