How to obtain the n-th letter of the alphabet

Is there a short formula to get the n-th letter of the alphabet?

For example, if I give parameter 5 to the function, I would get the letter e.

5 Answers

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.

1

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

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

0

There is also another simpler way: CHAR(CODE("A")+TRUNC(RAND()*26)).

1

This gives you the position of the letter in question (C3, for example) if it is capital or not.

=IF(AND(CODE(C3)>=65,CODE(C3)<=90),CODE(C3)-64,IF(AND(CODE(C3)>=97,CODE(C3)<=122),CODE(C3)-96,"Error")) 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like