[RESOLVED] Help with For Loop
I really struggle with loops error: End if block without if
I tried to create a second loop for Recipient
Sub SendEmail()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim cell2 As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Set OutlookApp = CreateObject("Outlook.Application")
For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "*@*" Then
For Each cell2 In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If IsEmpty(cell2.Value) Then
cell2.Value = ""
Subj = UserForm1.TextBox1.Text
Recipient = cell2.Value
EmailAddr = cell.Value
Msg = "Dear " & Recipient & vbCrLf & vbCrLf
Msg = UserForm1.TextBox2.Text
Msg = Msg & "Thanks." & vbCrLf & vbCrLf
Msg = Msg & "Chris"
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
SendKeys ("%{s}")
End With
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 5
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End If
Next
End Sub