Alphabet by number

goodfu

Registered User.
Local time
Today, 14:52
Joined
Dec 23, 2010
Messages
140
Is there a built-in function which will return "A" for 1, "B" for 2, "C" for 3, and so on up to "Z" for 26?
 
No. But check the function Asc, that gives the ASCII value of each character.
 
No, but you could store them in an array and then use the array index to relate them.
 
as spike says asc("A") is 65 - so you can convert a letter to a number by

asc(mystring)-64

Except ... by some magic access is able to sort "A" and "a" as being the same - but the ascii code for little a, is a different number to big A -

so you had better use

asc(ucase(mystring))-64


note that you can turn it back with chr() function

mystring = chr(somenumber+64)

also somewhat irritating having to use strings, when you mean a single letter - as unlike many languages, vba has no concept of a char. (single alphanumeric character)
 

Users who are viewing this thread

Back
Top Bottom