Function

Beginner

New Member
Joined
Jan 13, 2002
Messages
1
I am a new user of Excel and writing VBA functions. I am trying to write a function that looks at user input from a form text box and makes sure it is not blank and that it is text, not numbers. I am trying to use a select case statement, but can't get it to work.
 

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
Hello,

I know you posted this a long time ago, but I have only recently registered, and am trying to work my way through the unanswered posts, to gain as much experience as possible. I don't know if you need this any more, but I think I have come up with a solution.

Option Explicit
Dim CURRENT As String, enter As String

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
CURRENT = TextBox1.Text
If KeyAscii > 47 And KeyAscii < 66 Then
enter = MsgBox("TEXT ONLY", vbOKOnly, "TEXT ONLY")
KeyAscii = 0
End
End If
End Sub

Private Sub TextBox1_LostFocus()
If TextBox1.Text = "" Then
enter = MsgBox("EMPTY TEXT BOX", vbOKOnly, "EMPTY")
End If
End Sub

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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