![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Jan 2002
Posts: 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.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Aug 2003
Location: England
Posts: 4,644
|
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.
__________________
------------------------- Hope this is helpful. ------------------------- only a drafter, but broadening my Excel knowledge. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|