Excel - Convert Column Number to Column Reference
| 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 5 days ago
1 week 5 days ago
2 weeks 2 hours ago
2 weeks 1 day ago
2 weeks 2 days ago
2 weeks 5 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 14 hours ago
4 weeks 4 days ago