Expert Software Company : News

joi, 13 mai 2010

Excel - Convert Column Number to Column Reference

#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)

Niciun comentariu:

Trimiteți un comentariu