Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get a text/letters to equal to a percentage jose l. Excel Worksheet Functions 5 June 1st 09 02:10 PM
text to columns using capital letters Josh Craig Excel Discussion (Misc queries) 2 March 23rd 09 05:31 AM
Text to Columns Letters and Numbers Dot Excel Discussion (Misc queries) 5 July 27th 08 12:27 PM
Remove letters from text string John Calder New Users to Excel 3 May 14th 08 12:53 AM
How can I break down text in letters using VBA Berend Botje Excel Programming 7 June 2nd 04 05:17 PM


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"