keiranwyllie
New Member
- Joined
- May 12, 2017
- Messages
- 47
Hi folks,
I didn't want to hijack another thread so I'll start a new one here. When looking at this thread (https://www.mrexcel.com/forum/excel-questions/1102928-modifying-code-send-e-mail-3.html) I like the way the code creates a formatted email grabbing a range from a worksheet. In my case, I'd like to be able to achieve something similar with the following caveats:
I've been able to use the 'create pdf' code successfully but that still only captures all data in one file. It's not a show stopper however being able to create multiple emails means I can target specific people with email to only give me updates on the jobs they're currently working on (and not spam them with everyone else's jobs).
My worksheet (Report.xlsm) is located here - https://github.com/keiranwyllie/excel
This is the code that Worf provided in the above thread but I can't work out how to modify it to return the results I'm after.
Any and all guidance will be greatly appreciated.
Regards.
I didn't want to hijack another thread so I'll start a new one here. When looking at this thread (https://www.mrexcel.com/forum/excel-questions/1102928-modifying-code-send-e-mail-3.html) I like the way the code creates a formatted email grabbing a range from a worksheet. In my case, I'd like to be able to achieve something similar with the following caveats:
- Group rows into a formatted email based on the same names in column A
- Create as many new emails as there are different names in Column A
I've been able to use the 'create pdf' code successfully but that still only captures all data in one file. It's not a show stopper however being able to create multiple emails means I can target specific people with email to only give me updates on the jobs they're currently working on (and not spam them with everyone else's jobs).
My worksheet (Report.xlsm) is located here - https://github.com/keiranwyllie/excel
This is the code that Worf provided in the above thread but I can't work out how to modify it to return the results I'm after.
Code:
[COLOR=#333333]Sub main2() ' run me[/COLOR]Dim a(1 To 2), i%, rng As Range, OutApp As Object, om As Object, r%, f$
lr = Range("e" & Rows.Count).End(xlUp).Row
Sort
a(1) = CDbl(Cells(2, 5)) ' day one
a(2) = CDbl(a(1) + 1) ' day two
For i = 1 To 2
r = Evaluate("=sumproduct(max(row($e$2:$e$" & lr & ")*(" & a(i) & _
"=$e$2:$e$" & lr & ")))") + 1
Cells(r, 5).EntireRow.Insert
Cells(r, 5).EntireRow.Clear
Next
Set rng = Range("d2:d" & lr + 2)
f = "=NÚM.CARACT(D2)>0" ' Portuguese version
' f = "=len(d2)>0" ' use this one
rng.FormatConditions.Add Type:=xlExpression, Formula1:=f
rng.FormatConditions(rng.FormatConditions.Count).SetFirstPriority
With rng.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 6750207 ' yellow
.TintAndShade = 0
End With
rng.FormatConditions(1).StopIfTrue = 0
Set rng = Range("a1:f" & lr + 2)
Application.EnableEvents = 0
Set OutApp = CreateObject("Outlook.Application")
Set om = OutApp.CreateItem(0)
With om
.To = "ron@debruin.nl"
.CC = "carbon@copy.com"
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = RangetoHTML(rng)
.display
End With
With Application
.EnableEvents = True
.ScreenUpdating = 1
End With
Set om = Nothing
Set OutApp = Nothing
[COLOR=#333333]End Sub
[/COLOR]
Any and all guidance will be greatly appreciated.
Regards.