0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Excelの列番号(1, 2, 3, ...)を列文字(A, B, C, ...)に変換する関数

0
Posted at

マクロの処理の中でも使えるし、ワークシート関数としても使えます。

列番号 ⇒ 列文字
1 ⇒ A
26 ⇒ Z
27 ⇒ AA
52 ⇒ AZ
52 ⇒ BA

ColumnLetter.bas

Function ColumnLetter(ColumnNumber As Long)

    Dim q As Long
    Dim r As Long
    Dim s As String

    If ColumnNumber <= 0 Then
        ColumnLetter = CVErr(xlErrValue)
        Exit Function
    End If

    q = Int((ColumnNumber - 1) / 26)
    r = (ColumnNumber - 1) Mod 26

    If q > 0 Then
        s = ColumnLetter(q)
    End If

    ColumnLetter = s & Chr(65 + r)

End Function

参考:Excel の列番号を英文字に変換する方法

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?