M
Marcie
I am having trouble writing an If Then VBA that inserts the correct info into
my worksheet. See code below. I have a userform tha inserts all the info in
the correct rows but does not give me my answer.
Private Sub CommandButtonOk_Click()
If TextBoxName.Text = "" Then
MsgBox "You must enter a name."
Exit Sub
End If
NextBlankRow = Application.WorksheetFunction.CountA(Range("ColA")) + 1
'MsgBox (NextBlankRow)
Cells(NextBlankRow, 1) = TextBoxName.Text
Cells(NextBlankRow, 2) = TextBoxAge.Text
If TextBoxAge >= 3 And TextBoxAge <= 12 Then
Events = "Kids"
ElseIf TextBoxAge >= 13 And TextBoxAge <= 19 Then
Events = "Teens"
ElseIf TextBoxAge >= 20 And TextBoxAge <= 49 Then
Events = "Adults"
ElseIf TextBoxAge >= 50 Then
Events = "Seniors"
End If
TextBoxName.Text = ""
In Excel I have Column 3 named Events and when I type the name and age I
would like the the event column filled in based on the above data.
Can anyone help?
TextBoxAge.Text = ""
TextBoxName.SetFocus
End Sub
my worksheet. See code below. I have a userform tha inserts all the info in
the correct rows but does not give me my answer.
Private Sub CommandButtonOk_Click()
If TextBoxName.Text = "" Then
MsgBox "You must enter a name."
Exit Sub
End If
NextBlankRow = Application.WorksheetFunction.CountA(Range("ColA")) + 1
'MsgBox (NextBlankRow)
Cells(NextBlankRow, 1) = TextBoxName.Text
Cells(NextBlankRow, 2) = TextBoxAge.Text
If TextBoxAge >= 3 And TextBoxAge <= 12 Then
Events = "Kids"
ElseIf TextBoxAge >= 13 And TextBoxAge <= 19 Then
Events = "Teens"
ElseIf TextBoxAge >= 20 And TextBoxAge <= 49 Then
Events = "Adults"
ElseIf TextBoxAge >= 50 Then
Events = "Seniors"
End If
TextBoxName.Text = ""
In Excel I have Column 3 named Events and when I type the name and age I
would like the the event column filled in based on the above data.
Can anyone help?
TextBoxAge.Text = ""
TextBoxName.SetFocus
End Sub