Hi Team,
I've got a macro that will create an email based on the active cell and inputting relative content in to the email from the worksheet
As it stands, it only works on the activecell. How would I change my coding so that it does the active cell, then goes to the next row (same column) and repeats until the end.
Here's the code (I've had to strip out some of the HTML coding)
In the example, I would want an email to be formulated for Fred Bloggs, then another for Joe Soap then another for "Another Person" through to end.Sub Training_Enrolment_email() ' Working in Office 2000-2016 Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) strbody = "Dear " & ActiveCell.Offset(, -2) & ",<br/><br/>" & _ "This is an email<br/><br/>" & _ "In the body of the email will be <b>Colours for Deadline dates and other formatting<br/><br/>" & _ "GOOD LUCK and enjoy the training!<br/><br/>" & _ "Kindest Regards," On Error Resume Next With OutMail .Display .SentOnBehalfOfName = "Name of mailbox" .To = ActiveCell .CC = "" .BCC = "" .Subject = "Mandatory Training" .HTMLBody = strbody & "<br>" & .HTMLBody .Display '.Send will be used End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing 'Turn back on screen updating Application.ScreenUpdating = True End Sub
Any help would be greatly appreciated.
Bookmarks