Limiting InputBox to Letters only

firefiend

Board Regular
Joined
Feb 12, 2007
Messages
74
Okay, I have one last big issues for this project.

I have a InputBox in which I want to allow only Letters, NO NUMBERS.

Here's the code I have:

Code:
On Error GoTo ErrHandler:
Dim colLetter As String
colLetter = InputBox(Prompt:="Please enter product option." & _
    vbCr & "This function is NOT case sensitive.", _
    Title:="SELECT PRODUCT OPTION", Default:="<Column Letter>")
        If colLetter = "<Product Option>" Or _
            colLetter = vbNullString Or _
     **    colLetter = Number Then ** THIS IS THE CODE I NEED TO FIX
            GoTo ErrHandler:
            Else: GoTo nextQuestion:
        End If

But I'm not sure to make this distinction and my searches for the proper syntax have come up empty.

Any suggestions?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
On Error GoTo ErrHandler:
Dim colLetter As String
Dim a as string
a = IsNumber(colLetter)
colLetter = InputBox(Prompt:="Please enter product option." & _
vbCr & "This function is NOT case sensitive.", _
Title:="SELECT PRODUCT OPTION", Default:="<Column Letter>")
If colLetter = "<Product Option>" Or _
colLetter = vbNullString Or _
a = True Then
GoTo ErrHandler:
Else: GoTo nextQuestion:
End If
 
Upvote 0
That looks great ageren. I've seen the IsNumber function before but never used it.

I edited my code and am receiving a undefined sub or function error on IsNumber.

Any ideas on what is causing that?


EDIT: hmmm, I've changed the line to use IsNumeric instead of IsNumber... is this an identical function? Can anyone foresee any potential problems with this change?

and oh yeah, thanks everyone for the help. This is an awesome site and I'm having a blast chatting with you all while I learn VBA!
 
Upvote 0
please try like that; it is going to work now..

On Error GoTo ErrHandler:
Dim colLetter As String
Dim a as string
colLetter = InputBox(Prompt:="Please enter product option." & _
vbCr & "This function is NOT case sensitive.", _
Title:="SELECT PRODUCT OPTION", Default:="")
a = IsNumeric(colLetter)
If colLetter = "" Or _
colLetter = vbNullString Or _
a = True Then
GoTo ErrHandler:
Else: GoTo nextQuestion:
End If
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,727
Members
449,049
Latest member
MiguekHeka

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