Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
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
UserForm TextBoxes Rob Excel Discussion (Misc queries) 2 August 6th 05 03:07 AM
userform & textboxes beginner Excel Programming 3 July 27th 04 10:56 AM
userform textboxes again Jo[_6_] Excel Programming 4 October 21st 03 07:25 PM
userform textboxes Jo[_6_] Excel Programming 4 October 21st 03 07:15 PM
add numbers in textboxes on userform KimberlyC Excel Programming 5 September 18th 03 06:15 AM


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