Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Stipulation in command

I would like to add a stipulation to my sub that will check each text box for
a value. If a box is empty I would like the user to be directed to fill out
all information before they could continue.

Here is the sub:

Private Sub SaveCase_Click()

If Worksheets("Data").Range("A1") = "" Then

Worksheets("Data").Range("A1") = TBfud.Value
Worksheets("Data").Range("B1") = TBicd.Value
Worksheets("Data").Range("A1") = TBcn.Value

Else

Worksheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) =
TBfud.Value
Worksheets("Data").Range("B" & Rows.Count).End(xlUp).Offset(1, 0) =
TBicd.Value
Worksheets("Data").Range("C" & Rows.Count).End(xlUp).Offset(1, 0) = TBcn.Value


End If

MsgBox "Case Added" & vbCrLf & "Remember to save the file before you
close.", vbOKOnly, "Case Tracking File"

Sheets("Cases").TBfud.Value = ""
Sheets("Cases").TBicd.Value = ""
Sheets("Cases").TBcn.Value = ""

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Stipulation in command

Try something like this at the top of your code...

Private Sub SaveCase_Click()

If TBfud.Value = "" Or TBicd.Value = "" Or TBcn.Value = "" Then
Msgbox "Fill out the text boxes!"
Exit Sub
End If

'Rest of code here


HTH,
Bernie
MS Excel MVP


"Qaspec" wrote in message
...
I would like to add a stipulation to my sub that will check each text box for
a value. If a box is empty I would like the user to be directed to fill out
all information before they could continue.

Here is the sub:

Private Sub SaveCase_Click()

If Worksheets("Data").Range("A1") = "" Then

Worksheets("Data").Range("A1") = TBfud.Value
Worksheets("Data").Range("B1") = TBicd.Value
Worksheets("Data").Range("A1") = TBcn.Value

Else

Worksheets("Data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) =
TBfud.Value
Worksheets("Data").Range("B" & Rows.Count).End(xlUp).Offset(1, 0) =
TBicd.Value
Worksheets("Data").Range("C" & Rows.Count).End(xlUp).Offset(1, 0) = TBcn.Value


End If

MsgBox "Case Added" & vbCrLf & "Remember to save the file before you
close.", vbOKOnly, "Case Tracking File"

Sheets("Cases").TBfud.Value = ""
Sheets("Cases").TBicd.Value = ""
Sheets("Cases").TBcn.Value = ""

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
One command in one cell initiating another command in another cel. Chas52 Excel Worksheet Functions 3 November 7th 09 06:57 PM
command code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
I want to combine a "match" command with a copy and paste command. alomega Excel Programming 1 February 9th 05 05:52 PM


All times are GMT +1. The time now is 04:18 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"