如果值>阻止弹出0

时间:2015-03-27 15:46:44

标签: excel vba

我有一个带有以下代码的打印按钮: -

  Private Sub CommandButtonPrint_Click()
    MsgBox "Have you Completed the Email Address Field?", vbInformation
    response = MsgBox("Do you really want to print?", vbOKCancel)
    If response = vbCancel Then Exit Sub
    Sheets("New").PrintOut copies:=1, Collate:=True
    Range("newused").Select
   End Sub

这很好但是我需要添加什么来阻止第一个消息框“你有没有完成电子邮件地址字段?”如果电子邮件地址字段已经完成,则弹出。如果它已经完成,我只想要第二个消息框“你真的想打印>”弹出

1 个答案:

答案 0 :(得分:0)

您正在寻找类似这样的事情,您需要做的就是检查单元格是否为空。如果有效,请告诉我

Private Sub CommandButtonPrint_Click()
    Set rRng = Sheet1.Range("A10") 'Change to cell to email cell
    if IsEmpty(rRng.Value) then
        MsgBox "Have you Completed the Email Address Field?", vbInformation
    End If 
    response = MsgBox("Do you really want to print?", vbOKCancel)
    If response = vbCancel Then Exit Sub
    Sheets("New").PrintOut copies:=1, Collate:=True
    Range("newused").Select

 End Sub