ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make a cell mandatory before sending (https://www.excelbanter.com/excel-programming/313586-make-cell-mandatory-before-sending.html)

dmposey

Make a cell mandatory before sending
 
I have an excel form that is used to complete and inspection and then sent to
a particular person. I have a macro that they use for the SendMail function.
They are suppose to complete the Name & Phone number field but this does not
always get done. I want to make these cells mandatory before they are
allowed to email the form. Can someone tell me where to get the code? I
know very little VB code so please try to be very specific.

Thank you,
dmposey

Slick Willie

Make a cell mandatory before sending
 
Perhaps something like this:
If Cells(1,"A") = "" then
Response = msgbox("Please insert value in cell A1")
Else
SendMail code
End If
"dmposey" wrote in message ...
I have an excel form that is used to complete and inspection and then sent to
a particular person. I have a macro that they use for the SendMail function.
They are suppose to complete the Name & Phone number field but this does not
always get done. I want to make these cells mandatory before they are
allowed to email the form. Can someone tell me where to get the code? I
know very little VB code so please try to be very specific.

Thank you,
dmposey


dmposey

Make a cell mandatory before sending
 
Thanks Slick Willie. I'll try it in the morning and let you know how it works!

"Slick Willie" wrote:

Perhaps something like this:
If Cells(1,"A") = "" then
Response = msgbox("Please insert value in cell A1")
Else
SendMail code
End If
"dmposey" wrote in message ...
I have an excel form that is used to complete and inspection and then sent to
a particular person. I have a macro that they use for the SendMail function.
They are suppose to complete the Name & Phone number field but this does not
always get done. I want to make these cells mandatory before they are
allowed to email the form. Can someone tell me where to get the code? I
know very little VB code so please try to be very specific.

Thank you,
dmposey



dmposey

Make a cell mandatory before sending
 
I'm sure this is very simple, but I'm having problems with this code. I told
you I was a beginner! The form that I have created has 4 mandatory cells
that need to be completed. For each cell that is omitted, I want to display
a msgbox. Ex: Cell A2 requires their name. If cell A2 is "" then msgbox
"Please enter your name before submitting" else SendMail. Cell A5 requires
Phone Number: If cell A5 is "" then msgbox "Please enter Phone Number before
submitting" else SendMail.

What am I doing wrong?

here is what I have coded to a button:

Sub Button1_Click()

dim cells

If cells(2, a) = "" Then
MsgBox ("Please insert value in cell A2")
Else

ActiveWorkbook.SendMail Recipients:=""
End If

End Sub

"dmposey" wrote:

Thanks Slick Willie. I'll try it in the morning and let you know how it works!

"Slick Willie" wrote:

Perhaps something like this:
If Cells(1,"A") = "" then
Response = msgbox("Please insert value in cell A1")
Else
SendMail code
End If
"dmposey" wrote in message ...
I have an excel form that is used to complete and inspection and then sent to
a particular person. I have a macro that they use for the SendMail function.
They are suppose to complete the Name & Phone number field but this does not
always get done. I want to make these cells mandatory before they are
allowed to email the form. Can someone tell me where to get the code? I
know very little VB code so please try to be very specific.

Thank you,
dmposey



Slick Willie

Make a cell mandatory before sending
 
Certain words cannot be used as variables because they have special
meaning to Excel. Cells is one of those words, you shouldn't have to
declare it as a variable.
"dmposey" wrote in message ...
I'm sure this is very simple, but I'm having problems with this code. I told
you I was a beginner! The form that I have created has 4 mandatory cells
that need to be completed. For each cell that is omitted, I want to display
a msgbox. Ex: Cell A2 requires their name. If cell A2 is "" then msgbox
"Please enter your name before submitting" else SendMail. Cell A5 requires
Phone Number: If cell A5 is "" then msgbox "Please enter Phone Number before
submitting" else SendMail.

What am I doing wrong?

here is what I have coded to a button:

Sub Button1_Click()

dim cells

If cells(2, a) = "" Then
MsgBox ("Please insert value in cell A2")
Else

ActiveWorkbook.SendMail Recipients:=""
End If

End Sub



All times are GMT +1. The time now is 05:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com