- Hot Topics
Excel Get Letter from Number
Hi I have some code that gets the letter to the corresponding number Code: Function GetLetter(lNum As Long) As String If lNum <= 26 Then GetLetter = Chr(lNum + 64) Else GetLetter = Chr(Int((lNum - 1) / 26) + End If End Function I'm trying to do a similar thing but not with the alphabet, only with a string of letters in the alphabet. My string is "ABCDFGHIJKMQRSUVWXYZ" 20 characters. if the number is 22 this will return "AB" and 42 will return "BB" which is also correct. However after ZZ it goes wrong. of rexample if the number is 522 the it returns "BB" Hope this makes sense, here's my code so far. Code: Function Dim iCount As Long, iMax As Long, iPos strSearch = "ABCDFGHIJKMQRSUVWXYZ"
This question generated 28 answers. To proceed to the answers, click here.
This thread is current as of June 27, 2014.
For more resources for Microsoft Excel:
This article includes the following tags:
- Microsoft Excel