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 emails(confemails) to make sure all emails are in the correct format, if so: send email, if not: send a message an go to next list of emails but I keep having problems with the "Next j" and "Next i".
Compilation Error: Next without For
What am i doing wrong ?
CodePudding user response:
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
CodePudding user response:
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