I have created a sheet with the following macro to email the page in the body of an email to a specified distribution list.
Sub Email()
'Working in Excel 2002-2013
Dim Sendrng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Note: if the selection is one cell it will send the whole worksheet
Set Sendrng = Worksheets("Sheet1").Range("A1:G20")
'Remember the activesheet
Set AWorksheet = ActiveSheet
'Create the mail and send it
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "The PMC has received the following billing files. "
With .Item
'.To = "Anyone@anyplace.com"
.CC = ""
.BCC = ""
.Subject = "file arrival"
.Send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
This was working fine, except there has been errors by workers who are not confident in their ability to work in excel. A few critical cells have been left blank when sending the emails, leading to replies asking questions.
I have tried adding the following:
If Range("B2") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("D2") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("B3") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("D3") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C5") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C6") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C7") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C8") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C9") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C10") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C11") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C12") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C13") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("B16") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
And it gives a pop up notifying that certain cells need to be filled in (Copied from a different sheet that referred to only 1 cell)
I am trying to find a way for the macro to end here if any cells are left blank, and send if all cells have an entry.
Any help would be greatly appreciated.
Thank you, Keith
Sub Email()
'Working in Excel 2002-2013
Dim Sendrng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Note: if the selection is one cell it will send the whole worksheet
Set Sendrng = Worksheets("Sheet1").Range("A1:G20")
'Remember the activesheet
Set AWorksheet = ActiveSheet
'Create the mail and send it
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "The PMC has received the following billing files. "
With .Item
'.To = "Anyone@anyplace.com"
.CC = ""
.BCC = ""
.Subject = "file arrival"
.Send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
This was working fine, except there has been errors by workers who are not confident in their ability to work in excel. A few critical cells have been left blank when sending the emails, leading to replies asking questions.
I have tried adding the following:
If Range("B2") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("D2") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("B3") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("D3") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C5") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C6") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C7") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C8") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C9") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C10") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C11") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C12") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("C13") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
If Range("B16") = "" Then
i = MsgBox("Please put totals in all yellow cells", vbOKOnly + vbInformation, "Totals Sent!")
End If
And it gives a pop up notifying that certain cells need to be filled in (Copied from a different sheet that referred to only 1 cell)
I am trying to find a way for the macro to end here if any cells are left blank, and send if all cells have an entry.
Any help would be greatly appreciated.
Thank you, Keith