insomniac53
Board Regular
- Joined
- Sep 3, 2013
- Messages
- 104
I have been using this function for some time to convert a column number to letters. It should take any number and return the correct letters, even double letters, e.g. AH etc. It works, but there is at least one number which causes it to fail - that number is 36.
Here is the function:
When iCol is 35, function returns "AI" and when iCol is 37, function returns "AK" but when iCol is 36 function is undefined.
Can anyone see why it fails when iCol is 36 (and probably multiples of 36, too) ?
Thank you.
Here is the function:
Code:
Public Function ntc(ByVal iCol As Long) As String 'Number To String (returns ANY column LETTER)
If iCol Then ntc = ntc((iCol - 1) \ 26) & Chr(65 + (iCol - 1) Mod 26)
End Function
When iCol is 35, function returns "AI" and when iCol is 37, function returns "AK" but when iCol is 36 function is undefined.
Can anyone see why it fails when iCol is 36 (and probably multiples of 36, too) ?
Thank you.