如果单元格中没有条目,如何跳过,然后下一个 x

How to skip if no entry in cell, then next x

此代码发送电子邮件。在列表中,有时新员工还没有电子邮件地址。如果 Cells(x,2) 中的 .To 为空并转到 Next x?

,如何跳过创建电子邮件
    With OutMail
        .To = Cells(x, 2)
        .Subject = Cells(x, 3)
        'Change Body for email message here
        .Body = "Dear " & EmployeeName & "," & vbNewLine & vbNewLine & _
        "Attached is a copy of your check stub for this week." & vbNewLine & vbNewLine & _
          "Thank you," & vbNewLine & _
          "Moe Ballout"
                
        'Check if Attachment file exists, if not, then it will skip email
        If Dir(filename, vbNormal) <> "" Then
            .Attachments.Add (filename)
            '.Display
            .SendUsingAccount = OutApp.Session.Accounts(fromaccount)
            .Send
        End If

    End With
Next

End Sub
If Len(Cells(x, 2)) > 0 Then
  'your code that creates OutMail object
End If