>>I am looking for a quick function that I can use while coding excel automation. Is there a function that you can send a number to and get the alphabet position back for it? For example if I send a 1 I get back A, 3 a C...
>>
>>Happy New Year!!!!!
>
>If you want this on the VFP side sure, here's one;
>
>
>LPARAMETERS lnPosition
>LOCAL lcLetters
>lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>IF TYPE("lnPosition") <> "N" OR lnPosition < 0 OR lnPisiont > 26
> * Error bad parameter passed
>
>ENDIF
>RETURN SUBSTR(lcLetters,lnPosition,1)
>
Jim,
For numbers > 26 here is
lcColLetter = IIF(lnCol>26, CHR(Int((lnCol - 1) / 26) + 64), "") + CHR(((lnCol - 1) % 26) + 65)
from
http://berezniker.com/content/pages/visual-foxpro/excel-convert-column-number-column-reference
If it's not broken, fix it until it is.
My Blog