Vba on command button to check blank cells?

Closed
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

I have the following code on click of a command button, but i want it to check to see if certain cells are blank and error message if there are blank cells before sending the worksheet in an email.

Private Sub CommandButton1_Click()
ActiveWorkbook.SendMail Recipients:="jon@jonjon.com", Subject:=Range("G23").Value & "-" & Range("G37").Value & " - " & Range("G19").Value
End Sub

Can anyone help? Thanks in advance

JR

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
if the cell if they are blank or not before sending the mail

Private Sub CommandButton1_Click()
    
    If (Range("G23") = "") Then
        MsgBox "G23 is blank"
        Exit Sub
    End If
    
    ActiveWorkbook.SendMail Recipients:="jon@jonjon.com", Subject:=Range("G23").Value & "-" & Range("G37").Value & " - " & Range("G19").Value

End Sub
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month