Excel - Convert Column Number to Column Reference
By Sergey - Posted on January 1st, 2008
Tagged:
| This is sample code. Add error handling and adjust to your requirements as necessary. |
#DEFINE xlA1 1 #DEFINE xlR1C1 -4150 lnCol = 123 && Using Excel && oSheet - active sheet in a workbook lcColRef = oSheet.Cells(1,lnCol).Address(.T.,.F.,xlA1) &&lcColLetter = LEFT(lcColRef, AT("$", lcColRef)-1) lcColLetter = STREXTRACT(lcColRef, "", "$") && VFP code only lcColLetter = IIF(lnCol>26, CHR(Int((lnCol - 1) / 26) + 64), "") + CHR(((lnCol - 1) % 26) + 65)
Recent comments
1 week 23 hours ago
2 weeks 1 day ago
3 weeks 2 days ago
3 weeks 3 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 4 days ago
4 weeks 4 days ago
4 weeks 5 days ago
4 weeks 5 days ago