Reputation: 25
For i = 0 To lQtd
...
confemails = Split(EnviarPara, ";")
For j = 0 To UBound(confemails)
If EmailValido(confemails(j)) Then
Next j
Else
MsgBox "O e-mail" & confemails(j) & "Na linha" & i & "da tabela, foi digitado incorretamente, favor corrigir e enviar novamente."
Next i
EndIf
SendEmail
Next i
My problem is in the second For
.
The idea is to go through the list of email addresses (confemails) to make sure all email addresses are in the correct format.
If so: send email
If not: send a message and go to next list of email addresses
Compilation Error: Next without For
Upvotes: 0
Views: 83
Reputation: 16392
For i = 0 To lQtd
...
confemails = Split(EnviarPara, ";")
msg = ""
For j = 0 To UBound(confemails)
If Not EmailValido(confemails(j)) Then
msg = msg & " " & confemails(j)
End If
Next
If msg = "" Then
Sendmail
Else
MsgBox "O e-mail Na linha " & i & " da tabela, foi digitado incorretamente, favor corrigir e enviar novamente." & msg
End If
Next
Upvotes: 2
Reputation: 152660
You cannot have the Next inside the If block. Instead just do the Else:
For i = 0 To lQtd
...
confemails = Split(EnviarPara, ";")
For j = 0 To UBound(confemails)
If Not EmailValido(confemails(j)) Then
MsgBox "O e-mail" & confemails(j) & "Na linha" & i & "da tabela, foi digitado incorretamente, favor corrigir e enviar novamente."
Exit For
End If
SendEmail
Next j
Next i
Upvotes: 3