Vba on command button to check blank cells?

Closed
JR - Aug 12, 2010 at 06:26 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Aug 17, 2010 at 10:56 PM
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
Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Aug 17, 2010 at 10:56 PM
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