Created
December 3, 2014 01:06
-
-
Save dck-jp/3289715126246ff0265d to your computer and use it in GitHub Desktop.
Excelの列番号<->列名 変換
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '------------------------------------------------------------------------- | |
| ' 列番号<->列名 変換 | |
| '------------------------------------------------------------------------- | |
| '英文字を列番号値に変換 | |
| ''' @param strCol As String 変換する列文字列 | |
| Public Function L2N(strCol As String) | |
| L2N = Range(strCol & 1).column | |
| End Function | |
| '列番号値を同等の英文字に変換 | |
| ''' @param iCol As Integer 変換する列番号 | |
| Function N2L(iCol As Integer) As String | |
| Dim iAlpha As Integer | |
| Dim iRemainder As Integer | |
| iAlpha = Int((iCol - 1) / 26) | |
| iRemainder = iCol - (iAlpha * 26) | |
| If iAlpha > 0 Then | |
| N2L = Chr(iAlpha + 64) | |
| End If | |
| If iRemainder > 0 Then | |
| N2L = N2L & Chr(iRemainder + 64) | |
| End If | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment