Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorry about the last ones...And statements with IF's
I am trying to put a function into this user box so that if one of th
textboxes are empty, then nothing gets entered into the sheet. Ca anyone help? I am stumped. I greatly appreciate it. Private Sub OK_Click() 'This all happens when OK is clicked. 'if the first textbox is blank, then a message box pops up 'to tell you a value must be entered. If TextBox1 = "" Then MsgBox "you must enter a name" Range("a1") = TextBox1.Value If TextBox2 = "" Then MsgBox "you must enter an age" Range("a2") = TextBox2.Value If TextBox3 = "" Then MsgBox "you must enter a gender" Range("a3") = TextBox3.Value 'clears the text boxes for next use TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" 'sets the cursor in textbox1 TextBox1.SetFocus 'hides the userform when ok is clicked Me.Hide End Su -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorry about the last ones...And statements with IF's
trickdos,
The following is code that I came up with, but what you want is rreally more than what you asked for. This will do as you asked. Charles Private Sub CommandButton1_Click() With UserForm1 If .TextBox1.Value = "" Then MsgBox " You must enter a name" ..TextBox1.SetFocus Exit Sub ElseIf .TextBox2.Value = "" Then MsgBox " You must enter age" ..TextBox2.SetFocus Exit Sub ElseIf .TextBox3.Value = "" Then MsgBox " You must enter gender" ..TextBox3.SetFocus Exit Sub End If Range("A1").Value = .TextBox1.Text Range("A2").Value = .TextBox2.Text Range("A3").Value = .TextBox3.Text ..TextBox1 = "" ..TextBox2 = "" ..TextBox3 = "" Unload UserForm1 End With End Sub --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sum with 2 if's | Excel Worksheet Functions | |||
Or's with If's Statements | Excel Discussion (Misc queries) | |||
Too many 'if's! | Excel Discussion (Misc queries) | |||
Too Many If's | Excel Worksheet Functions | |||
IF's | Excel Worksheet Functions |