Userform Error

drc2265

Board Regular
Joined
Jul 30, 2007
Messages
96
Hello,

I currently have:

Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox3.Value Like "*[!0-9]*" Then
MsgBox "You must provide a numeric value in this TextBox!"
Cancel = True
ElseIf TextBox3.Value > 26 Then
MsgBox "Invalid Pick!"
Cancel = True
ElseIf TextBox3.Value < 1 Then
MsgBox "Invalid Pick!"
Cancel = True
End If
End Sub

Private Sub TextBox4_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox4.Value Like "*[!0-9]*" Then
MsgBox "You must provide a numeric value in this TextBox!"
Cancel = True
ElseIf TextBox4.Value > 26 Then
MsgBox "Invalid Pick!"
Cancel = True
ElseIf TextBox4.Value < 1 Then
MsgBox "Invalid Pick!"
Cancel = True
End If
End Sub

The Invalid Pick message pops up, once clicked I am getting a error message: run-time error - unspecified error, forcing to close the form and reopen.

I appreciate any help.

Thanks,
DC
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This works for me

Code:
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim v As Variant:       v = TextBox3.Value
    
    If Not IsNumeric(v) Or v > 26 Or v < 1 Then
        MsgBox "You must provide a numeric value between 1 and 26 in this TextBox!"
        Cancel = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top