Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
only letters in text box
I know about the IsNumber function. I was wondering if there is a similar
function to only allow letters in the text box. The IsText worksheet function won't cut it. Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
only letters in text box
This allows keyboard entries space, A-Z and a-z only:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case 32, 65 To 90, 97 To 122 Case Else KeyAscii = 0 End Select End Sub See or make a character map for other allowed characters and symbols. This does not handle Ctrl V, do that with code in the KeyDown event if required. HTH. Best wishes Harald. "JNW" skrev i melding ... I know about the IsNumber function. I was wondering if there is a similar function to only allow letters in the text box. The IsText worksheet function won't cut it. Thanks! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
only letters in text box
There is no Excel worksheet or VB function that can directly tell you if a
string has any numeric characters. You could use this perhaps: Sub TestOK() MsgBox StrHasNoNums("abc") End Sub Sub TestBad() MsgBox StrHasNoNums("a2c") End Sub Function StrHasNoNums(Str As String) As Boolean Dim Counter As Integer Dim ThisChar As String For Counter = 1 To Len(Str) ThisChar = Mid(Str, Counter, 1) If ThisChar <= "9" Then If ThisChar = "0" Then Exit Function End If Next StrHasNoNums = True End Function -- Jim "JNW" wrote in message ... |I know about the IsNumber function. I was wondering if there is a similar | function to only allow letters in the text box. The IsText worksheet | function won't cut it. | | Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to get a text/letters to equal to a percentage | Excel Worksheet Functions | |||
text to columns using capital letters | Excel Discussion (Misc queries) | |||
Text to Columns Letters and Numbers | Excel Discussion (Misc queries) | |||
Remove letters from text string | New Users to Excel | |||
How can I break down text in letters using VBA | Excel Programming |