Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel UserForm issues: Textboxes cannot be blank
I'm extremely new to this and I'm trying to use userforms for data
entry on a spreadsheet in excel. Im having issues with some of the data entry. This is what I have so far: Private Sub CommandButton1_Click() ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox1 Range("K36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox2 Range("L36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox3 Unload Me CJOForm.Show End Sub Private Sub CommandButton2_Click() ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox1 Range("K36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox2 Range("L36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox3 Unload Me End Sub Private Sub UserForm_Click() txtName.Value = "" txtDate.Value = "" txtName.SetFocus End Sub I want it to not let the person skip a textbox without entering some information in. Right now, If i dont enter in an data, and click the "done" command button it closes and enters no text but when I open the form again it acts like there is text entered into the empty cells. Does this even make sense? I'm not sure if I'm explaining myself well. Please help! I've been working on this for hours and I just want to be done! Jennifer |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel UserForm issues: Textboxes cannot be blank
Private Sub CommandButton1_Click()
With textbox1 If .Text = "" Then MsgBox "Must complete textbox1" .SetFocus Exit Sub End If End With With textbox2 If .Text = "" Then MsgBox "Must complete textbox2" .SetFocus Exit Sub End If End With With textbox3 If .Text = "" Then MsgBox "Must complete textbox3" .SetFocus Exit Sub End If End With ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").End(xlDown).Offset(1, 0).Value = textbox1.Text Range("K36").End(xlDown).Offset(1, 0).Value = textbox2.Text Range("L36").End(xlDown).Offset(1, 0).Value = textbox3.Text Unload Me CJOForm.Show End Sub Private Sub CommandButton2_Click() With textbox1 If .Text = "" Then MsgBox "Must complete textbox1" .SetFocus Exit Sub End If End With With textbox2 If .Text = "" Then MsgBox "Must complete textbox2" .SetFocus Exit Sub End If End With With textbox3 If .Text = "" Then MsgBox "Must complete textbox3" .SetFocus Exit Sub End If End With ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").End(xlDown).Offset(1, 0).Value = textbox1.Text Range("K36").End(xlDown).Offset(1, 0).Value = textbox2.Text Range("L36").End(xlDown).Offset(1, 0).Value = textbox3.Text Unload Me End Sub Private Sub UserForm_Click() txtName.Value = "" txtDate.Value = "" txtName.SetFocus End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) wrote in message ups.com... I'm extremely new to this and I'm trying to use userforms for data entry on a spreadsheet in excel. Im having issues with some of the data entry. This is what I have so far: Private Sub CommandButton1_Click() ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox1 Range("K36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox2 Range("L36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox3 Unload Me CJOForm.Show End Sub Private Sub CommandButton2_Click() ActiveWorkbook.Sheets("Sheet2").Activate Range("J36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox1 Range("K36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox2 Range("L36").Select Do If IsEmpty(ActiveCell) = False Then ActiveCell.Offset(1, 0).Select End If Loop Until IsEmpty(ActiveCell) = True ActiveCell.Value = TextBox3 Unload Me End Sub Private Sub UserForm_Click() txtName.Value = "" txtDate.Value = "" txtName.SetFocus End Sub I want it to not let the person skip a textbox without entering some information in. Right now, If i dont enter in an data, and click the "done" command button it closes and enters no text but when I open the form again it acts like there is text entered into the empty cells. Does this even make sense? I'm not sure if I'm explaining myself well. Please help! I've been working on this for hours and I just want to be done! Jennifer |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UserForm TextBoxes | Excel Discussion (Misc queries) | |||
userform & textboxes | Excel Programming | |||
userform textboxes again | Excel Programming | |||
userform textboxes | Excel Programming | |||
add numbers in textboxes on userform | Excel Programming |