Crues
Crues

Reputation: 165

Incooperation of a changing date into an e-mail text via VBA

I have got text attached to an email. My aim is to incorporate the date, which states in a worksheet in the range E2 into the text (e.g. as illustrated below Juni 2018).

datDate=WorksheetFunction.Max(Sheets("Description").Range("E2"))

strText="<span style='font-size:10.0pt;font-family:""Arial"",""sans-serif"";" & _
    "color:black'>Hello,<br><br>please find attached the Report " & _
    "for ***Juni 2018***.<br><br>"

Upvotes: 0

Views: 32

Answers (1)

ashleedawg
ashleedawg

Reputation: 21639

Assuming datDate is correctly holding the date in question, you could use:

strText = "<span style='font-size:10.0pt;font-family:""Arial"",""sans-serif"";" & _
    "color:black'>Hello,<br><br>please find attached the Report " & _
    "via ***" & Format(datDate, "MMMM yyyy") & "***.<br><br>"

Also, I know you didn't ask for grammar advice but I figured I'd point out that "via" is not the correct word in this case. ("Via" would be used to name a location that an item travelled through on the way to it's destination.)

for is the word I would use. :)

Upvotes: 1

Related Questions