need a function for numbers to characters

E

Eric Marple

Is there a method or function that will take a number and
give me the corresponding character?
 
J

JulieD

Hi Eric

if we're talking about ANSI numbers e.g. 64 = @ and 65 = A etc
then you can use the CHAR function
e.g. =CHAR(A1)

Regards
JulieD
 
J

Jim Cone

Eric,

Give this a try...
'-------------------------------------------------
'Jim Cone - August 05, 2004
'Returns alphabetic equivalent of provided number.
'Returns nothing for numbers > 256.

Function GetLetters(ByVal ColumnNum As Long) As String
On Error GoTo NoNumber
Dim ColChars As String
ColChars = Columns(ColumnNum).Address(False, False)
GetLetters = Left$(ColChars, 1)
Exit Function
NoNumber:
Beep
GetLetters = vbNullString
End Function

'Call it this way...

Sub GetLetter()
Dim strAlpha As String
strAlpha = GetLetters(25)
MsgBox strAlpha
End Sub
'-------------------------------------------------

Regards,
Jim Cone
San Francisco, CA
 
R

Ron Rosenfeld

If I pass 1 I want A returned, 2 = b, 3 = c and so forth

If your number is in A1, then =CHAR(A1+64) will give you an "A" for 1, but it
will give you a "B" for 2, not a "b".

What kind of rule do you want to use to decide between "B" and "b" as well as
for the other letters of the alphabet?


--ron
 
Top