|
-
Mar 29th, 2007, 12:10 PM
#1
Thread Starter
Lively Member
[RESOLVED] is there a method like "isAlphabetic"
Hello,
I see where VBA has a method or property called "isNumeric" but i can't seem to find a similar version for the characters a to z, ie something like "isAlphbetic" or "isCharacter" ect?
Thanks for any pointers!
BobK
-
Mar 29th, 2007, 12:58 PM
#2
Addicted Member
Re: is there a method like "isAlphabetic"
wouldn't this work for you?
-
Mar 29th, 2007, 01:31 PM
#3
Thread Starter
Lively Member
Re: is there a method like "isAlphabetic"
yes that would work for the most part, but i think i'd also be pickup control characters and so on maybe?
actually, i was hoping there would be something that would zero in on the alphabet, but i'm going to try (not IsNumeric) and see what happens!
thanks for your response on this!
bobk
-
Mar 29th, 2007, 02:04 PM
#4
Re: is there a method like "isAlphabetic"
Isnumeric is working on a Variant, I guess you need to check each character, if that's correct remember that the ASCII codes for alphabets are all within a defined range, use that to check if each character is alphabetical.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 29th, 2007, 02:09 PM
#5
Re: is there a method like "isAlphabetic"
Hi
I am not sure if there is any such function or not but YES! you can create one...
Paste this in as module.
vb Code:
Function isalpha(str As String) As Boolean
Dim Flag As Boolean
Flag = True
For i = 1 To Len(Trim(str))
If Asc(Mid(Trim(str), i, 1)) > 64 And Asc(Mid(Trim(str), i, 1)) < 90 Or _
Asc(Mid(Trim(str), i, 1)) > 96 And Asc(Mid(Trim(str), i, 1)) < 123 Then
Else
Flag = False
End If
Next i
If Flag = True Then
isalpha = True
Else
isalpha = False
End If
End Function
In an excel sheet use the function as =isalpha(A1). Where A1 is the cell where you enter the word you want to test.
If the word you entered contains all letters then the above function will return true. If even 1 letter is numeric then the above function will return false...
Hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 29th, 2007, 02:27 PM
#6
Thread Starter
Lively Member
Re: is there a method like "isAlphabetic"
Thanks all, loooks good appreciate the excellent! help!
BobK
-
Mar 29th, 2007, 02:31 PM
#7
Addicted Member
Re: [RESOLVED] is there a method like "isAlphabetic"
koolsid knows too much lol
-
Mar 29th, 2007, 03:34 PM
#8
Re: [RESOLVED] is there a method like "isAlphabetic"
Thanks all, loooks good appreciate the excellent! help!
Glad to be of help 
koolsid knows too much lol
Thanks for the compliment but wish I knew 'that' much
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 29th, 2007, 03:48 PM
#9
Addicted Member
Re: [RESOLVED] is there a method like "isAlphabetic"
how did you get you know as much as you do?
i'm just startin out really, playing around etc
bought john walkenbachs new book ,been told its quite good!
-
Mar 29th, 2007, 07:30 PM
#10
Addicted Member
Re: [RESOLVED] is there a method like "isAlphabetic"
lol that'll do me
-
Mar 29th, 2007, 08:43 PM
#11
Fanatic Member
Re: [RESOLVED] is there a method like "isAlphabetic"
 Originally Posted by Mitch_s_s
bought john walkenbachs new book ,been told its quite good!
I have his Excel 2000 edition and it is falling apart from constant use! As a 2nd book, I've found VBA Developer's Handbook by Getz to be a great follow-on....
Last edited by VBAhack; Mar 30th, 2007 at 05:27 PM.
-
Mar 30th, 2007, 12:33 AM
#12
Re: [RESOLVED] is there a method like "isAlphabetic"
The function could be shortened like this:
Code:
Function isalpha(str As String) As Boolean
isalpha = True
For i = 1 To Len(Trim(str))
If Asc(Mid(Trim(str), i, 1)) > 64 And Asc(Mid(Trim(str), i, 1)) < 90 Or _
Asc(Mid(Trim(str), i, 1)) > 96 And Asc(Mid(Trim(str), i, 1)) < 123 Then
Else
isalpha = False
Exit Function
End If
Next i
End Function
And note that in other languages there will be more alphabetical characters (like "ä" [if this one shows on your computer]).
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 30th, 2007, 12:21 PM
#13
Fanatic Member
Re: [RESOLVED] is there a method like "isAlphabetic"
 Originally Posted by opus
The function could be shortened like this:
Or this:
Code:
Function isalpha(str As String) As Boolean
Dim i As Integer, k As Integer
isalpha = True
For i = 1 To Len(Trim(str))
k = Asc(Mid(Trim(str), i, 1))
If k > 64 And k < 90 Or k > 96 And k < 123 Then
Else
isalpha = False
Exit Function
End If
Next i
End Function
-
Mar 30th, 2007, 12:43 PM
#14
Thread Starter
Lively Member
Re: [RESOLVED] is there a method like "isAlphabetic"
Thanks again all, super help!
BobK
-
Mar 30th, 2007, 01:15 PM
#15
Re: [RESOLVED] is there a method like "isAlphabetic"
When you are comparing the same value multiple times in an If statement (or multiple If statements), a Select Case is more efficient..
Code:
Function isalpha(str As String) As Boolean
Dim i As Integer
isalpha = True
For i = 1 To Len(Trim(str))
Select Case Mid$(Trim(str), i, 1)
Case "A" to "Z", "a" to "z"
Case Else
isalpha = False
Exit For
End Select
Next i
End Function
..using one less function (Asc) makes it more efficient too, and a bit more readable.
-
Mar 30th, 2007, 01:20 PM
#16
Fanatic Member
Re: [RESOLVED] is there a method like "isAlphabetic"
Nice one Si!
-
Mar 30th, 2007, 04:29 PM
#17
Addicted Member
Re: [RESOLVED] is there a method like "isAlphabetic"
 Originally Posted by VBAhack
I have his Excel 2000 edition and it is falling apart from constant use! As a 2nd book, I've found VBA Developer's Handbood by Getz to be a great follow-on....
thanks for that, i will look into once i've got stuck into this one!!
Cheers!
Last edited by Mitch_s_s; Mar 30th, 2007 at 04:33 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|