willow1985
Well-known Member
- Joined
- Jul 24, 2019
- Messages
- 929
- Office Version
- 365
- Platform
- Windows
Hello,
I have the below Macro that takes data, puts it in an email and then pulls a recipient list from that same data, however the problem I am having is if there is a duplicate email address in the list it sends a duplicate email to that recipient. Is there a way to modify this so it sends unique values only? (Only emails a recipient one time?)
I got help with the below code from someone on this board so I do not know how to modify it or even a code that would grab only the unique values from column M.
Thank you to anyone who can help!!
I have the below Macro that takes data, puts it in an email and then pulls a recipient list from that same data, however the problem I am having is if there is a duplicate email address in the list it sends a duplicate email to that recipient. Is there a way to modify this so it sends unique values only? (Only emails a recipient one time?)
I got help with the below code from someone on this board so I do not know how to modify it or even a code that would grab only the unique values from column M.
Thank you to anyone who can help!!
VBA Code:
Sub sendmail2()
'
' sendmail2 Macro
'
Application.ScreenUpdating = False
Worksheets("Automatic Emails").Visible = True
Dim OutlookApp As Object, MItem As Object, cad As String
Dim i As Long, sh As Worksheet, rng As Range, lr As Long
Set sh = Sheets("Automatic Emails")
lr = sh.Range("AD" & Rows.Count).End(xlUp).Row
For i = 2 To lr
cad = cad & sh.Range("AD" & i).Value & "; "
Next
Set OutlookApp = CreateObject("Outlook.Application")
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = sh.Range("AD1").Value & ";" & sh.Range("AD2").Value
.Subject = "Audit Schedule UPDATE REQUIRED"
.htmlBody = "<br>AUDIT LIST UPDATE REQUIRED THE DIVISION FOR UPCOMING YEAR<br>" & _
"<br>[This is an Automated Message - Do not reply]<br>" & _
"Audit Scheduler"
.Display
.Send
End With
Application.ScreenUpdating = True
Worksheets("Automatic Emails").Visible = False
End Sub
Cadorath Internal Audit Schedule.xlsm | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | Scheduled Month: | Element: | Severity Level: | Auditor: | Date Completed: | Filed Y/N | Previous Audit Date | Finding Raised Y/N: | CAPA #: | Flag Date | Due Date | Link to Audit form | Email List | ||
2 | April | Process Audit 2 | 2020-06-26 | 2021-05-26 | 2021-06-26 | \\DAVINCI-1\CADODATA\QA_MANUALS\Audit%20Forms\ISO\Uniflyte%20Process%20Audit%202%20%20Product%20Realization.doc | |||||||||
3 | April | Coatings Process Audit 2 | Ed | 2020-06-18 | 2021-05-18 | 2021-06-18 | \\DAVINCI-1\CADODATA\QA_MANUALS\Audit%20Forms\ISO\Coatings%20Process%20Audit%202%20Repairs%20Processes%20Product%20Realization.doc | Ed@noemail.com | |||||||
4 | August | Coatings Process Audit 6 | N/A | Shane | 2019-10-30 | 2020-09-30 | 2020-10-30 | \\DAVINCI-1\CADODATA\QA_MANUALS\Audit%20Forms\ISO\Uniflyte%20Process%20Audit%206%20Quality%20System%20.doc | shane@noemail.com | ||||||
5 | May | CADI PCSM Audit | Ed | 2019-07-26 | 2020-06-26 | 2020-07-26 | \\DAVINCI-1\CADODATA\QA_MANUALS\Audit%20Forms\ISO\PCSM%20Audit%20Checklist%20Rev%203.doc | Ed@noemail.com | |||||||
Automatic Emails |
Cell Formulas | ||
---|---|---|
Range | Formula | |
L2:L5 | L2 | =INDEX(W:W,MATCH(B2,V:V,FALSE)) |
M2:M5 | M2 | =IFERROR(INDEX(O:O,MATCH(D2,N:N,FALSE)),"") |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
F1 | List | ='Audit List'!$F$1:$F$2 |