Hello,
I have a for each loop that is pulling email addresses to set as recipients of emails. Thing is, it pulls emails "for each" clientCode - some clientCodes have multiple email addresses and thus have multiple rows. These emails need to have all email addresses as recipients and right now this loop is only addressing these to the first email address and skipping over the rest (if there are more than one).
i.e. )
client code email address
A 1@ex.com
A 2@ex.com
B 1@ex.com
B 2@ex.com
I bolded the examples that this loop adds as recipients, as you can see it is skipping email addresses for which there are multiple contacts for one client code. Can someone help me edit this to make sure it pulls all email addresses for which a client code is the same? Below is a piece of the VBA script I have.
Thanks to all in advance.
Best,
-Kev
I have a for each loop that is pulling email addresses to set as recipients of emails. Thing is, it pulls emails "for each" clientCode - some clientCodes have multiple email addresses and thus have multiple rows. These emails need to have all email addresses as recipients and right now this loop is only addressing these to the first email address and skipping over the rest (if there are more than one).
i.e. )
client code email address
A 1@ex.com
A 2@ex.com
B 1@ex.com
B 2@ex.com
I bolded the examples that this loop adds as recipients, as you can see it is skipping email addresses for which there are multiple contacts for one client code. Can someone help me edit this to make sure it pulls all email addresses for which a client code is the same? Below is a piece of the VBA script I have.
Code:
For Each rw In ThisWorkbook.Sheets("Client Contact Info").ListObjects("ClientContacts").ListRows
'findrows for client code
If ThisWorkbook.Sheets("Client Contact Info").Range("A" & rw.Range.Row).Value = clientCode Then
'SetRecipients
Recipients = Recipients & ThisWorkbook.Sheets("Client Contact Info").Range("B" & rw.Range.Row).Value & ";"
End If
Next rw
Thanks to all in advance.
Best,
-Kev