Hi Team, I am having issues trying to create a loop for this Macro I build. The goal is to have excel run a basic standard email to our vendors, however, I cannot seem to find a loop to move on to the next range.
Right now the Range is for C4:D4, after the email is complete I want the same action to begin but for C5:D5, and stops when it hits a blank.
Thank you all so much for helping, I am excited to see this.
MACRO
Sub Email_Template()
Dim emailApplication As Object
Dim emailItem As Object
Dim emailRng As Range, CL As Range
Dim sTO As String
' C - Primary Email / D - Secondary Email
Set emailRng = Worksheets("Sheet1").Range("C4:D4")
For Each CL In emailRng
sTO = sTO & ";" & CL.Value
Next
sTO = Mid(sTO, 2)
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
' Building the email'
emailItem.to = sTO
emailItem.Subject = "UPDATE"
emailItem.Body = "TEST TEST TEST"
emailItem.Display
'emailItem.Send
Set emailItem = Nothing
Set emailApplication = Nothing
End Sub
Right now the Range is for C4:D4, after the email is complete I want the same action to begin but for C5:D5, and stops when it hits a blank.
Thank you all so much for helping, I am excited to see this.
MACRO
Sub Email_Template()
Dim emailApplication As Object
Dim emailItem As Object
Dim emailRng As Range, CL As Range
Dim sTO As String
' C - Primary Email / D - Secondary Email
Set emailRng = Worksheets("Sheet1").Range("C4:D4")
For Each CL In emailRng
sTO = sTO & ";" & CL.Value
Next
sTO = Mid(sTO, 2)
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
' Building the email'
emailItem.to = sTO
emailItem.Subject = "UPDATE"
emailItem.Body = "TEST TEST TEST"
emailItem.Display
'emailItem.Send
Set emailItem = Nothing
Set emailApplication = Nothing
End Sub