Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Required Fields in Excel Application?

I have an Excel sheet that has a script attached to a button that will email
the form via outlook once the button is pressed. Anyway, is there any way to
make certain fields required before the email is sent and produce an error
message if those fields are left blank? Cells D13 and D14 would be the ones
in question. I have my code below. Thanks

Private Sub CommandButton1_Click()

Dim wb As Workbook
Dim strdate As String
Dim MyArr As Variant
MyArr = Sheets("EmailAddresses").Range("a2:a25")
strdate = Format(Now, "mm-dd-yy")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail MyArr, "LOA Notice - " & Sheets("STD-LOA").Range("d8")
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Required Fields in Excel Application?

Private Sub CommandButton1_Click()

Dim wb As Workbook
Dim strdate As String
Dim MyArr As Variant
MyArr = Sheets("EmailAddresses").Range("a2:a25")
strdate = Format(Now, "mm-dd-yy")
if Range("D13") = "" or Range("D14") = "" then
msgbox "Missing Data, quitting"
exit sub
end if
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail MyArr, "LOA Notice - " & Sheets("STD-LOA").Range("d8")
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

--
Regards,
Tom Ogilvy

"Nash13" wrote:

I have an Excel sheet that has a script attached to a button that will email
the form via outlook once the button is pressed. Anyway, is there any way to
make certain fields required before the email is sent and produce an error
message if those fields are left blank? Cells D13 and D14 would be the ones
in question. I have my code below. Thanks

Private Sub CommandButton1_Click()

Dim wb As Workbook
Dim strdate As String
Dim MyArr As Variant
MyArr = Sheets("EmailAddresses").Range("a2:a25")
strdate = Format(Now, "mm-dd-yy")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail MyArr, "LOA Notice - " & Sheets("STD-LOA").Range("d8")
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Required Fields in Excel Application?

Nash,

Add the following code at the beginning of your code

if Sheets("EmailAddresses").range("D13").value = "" or
Sheets("EmailAddresses").range("D14").value = "" then
msgbox "Can not sent, please enter all required field",vbcritical,"Error"
exit sub
end if

"Nash13" wrote:

I have an Excel sheet that has a script attached to a button that will email
the form via outlook once the button is pressed. Anyway, is there any way to
make certain fields required before the email is sent and produce an error
message if those fields are left blank? Cells D13 and D14 would be the ones
in question. I have my code below. Thanks

Private Sub CommandButton1_Click()

Dim wb As Workbook
Dim strdate As String
Dim MyArr As Variant
MyArr = Sheets("EmailAddresses").Range("a2:a25")
strdate = Format(Now, "mm-dd-yy")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail MyArr, "LOA Notice - " & Sheets("STD-LOA").Range("d8")
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Required Fields in Excel Application?

Great. Thank you both. I took those examples and made D14 dependent on D13.
Awesome.

"Brotha Lee" wrote:

Nash,

Add the following code at the beginning of your code

if Sheets("EmailAddresses").range("D13").value = "" or
Sheets("EmailAddresses").range("D14").value = "" then
msgbox "Can not sent, please enter all required field",vbcritical,"Error"
exit sub
end if

"Nash13" wrote:

I have an Excel sheet that has a script attached to a button that will email
the form via outlook once the button is pressed. Anyway, is there any way to
make certain fields required before the email is sent and produce an error
message if those fields are left blank? Cells D13 and D14 would be the ones
in question. I have my code below. Thanks

Private Sub CommandButton1_Click()

Dim wb As Workbook
Dim strdate As String
Dim MyArr As Variant
MyArr = Sheets("EmailAddresses").Range("a2:a25")
strdate = Format(Now, "mm-dd-yy")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail MyArr, "LOA Notice - " & Sheets("STD-LOA").Range("d8")
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Required fields in Excel [email protected] New Users to Excel 5 November 4th 10 05:33 PM
how to have fields to be required Mandatory fields in Excel Excel Worksheet Functions 1 June 6th 08 10:41 PM
Feature to flag unpopulated required fields in Excel? Sarah Excel Discussion (Misc queries) 1 February 27th 06 08:02 PM
Required fields Lupe[_2_] Excel Programming 1 June 2nd 04 02:50 PM
Load Testing Tool required for Excel Pivot table based OLAP Application Shanmugavel R P Excel Programming 2 March 1st 04 11:01 AM


All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"