Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Function

  1. #1
    New Member
    Join Date
    Jan 2002
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)


    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. #2
    Board Regular
    Join Date
    Aug 2003
    Post Thanks / Like
    3 Post(s)
    1 Thread(s)

    Default Re: Function


    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 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.

    Have been away from the forum for quite a while, but am now back.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts