views:

418

answers:

3

Hi,

is there a short formula to get the xth letter of the alphabet?

So if I give parameter '5' to the function, I would get the letter 'e'.

thanks!

A: 

you could use an ascii function since every letter has a numeric value in ascii

Not sure what language your using... in T-SQL you can use an ASCII and CHAR functions:

PRINT CHAR(ASCII('A') + @i) -- where @i is your numeric value

Chris Klepeis
There is T-SQL in Excel?
Joey
+4  A: 

There is a function CHAR which gives a character with the specified code:

CHAR(96 + 5)

will yield your "e".

But there is no direct way to get a character of the alphabet.

Joey
good enough for me... Thanks!
Fortega
A: 

An alternate, although not as short as the CHAR function, is the CHOOSE function

=CHOOSE(5,"a","b","c","d","e","f","g","h","I","j","k","l","m",
        "n","o","p","q","r","s","t","u","v","w","x","y","z")

The index number '5' returns the fifth value in the list. The list could be an Excel range of data e.g. (A1:A26).

If the index number is outside the range, #VALUE! is returned

Robert Mearns