如果值> 0,则防止popup

我有一个打印button,下面的代码: –

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 

这工作正常,但我需要添加,以防止第一个消息框“你有没有完成电子邮件地址字段? popup如果电子邮件地址字段已经完成。 如果它已经完成,我只想要第二个消息框“你真的想打印”popup

你正在寻找这样的事情,你需要做的是检查单元格是否为空。 让我知道这个是否奏效

 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