pgbigorokuのブログ

プログラムの再利用できそうなコードをアップ

EXCEL VBA マクロを組むとき列番号の把握をしやすいよう、シートの1行目に列番号を記入する

マクロを組むとき列番号の把握をしやすいよう、シートの1行目に列番号を記入します。
既に値が入ったセルには書き込みません。

Public Sub test()
    Call nisub列番号を1行目に挿入
End Sub



'
' 1行目に列番号を入れる。
'https://pgbigoroku.hatenablog.com/entry/2022/08/24/154418
'2022/8/15
Public Sub nisub列番号を1行目に挿入(Optional ByVal pint最終列 As Integer = 100)
    Dim intCol As Integer
    For intCol = 1 To pint最終列
        If Cells(1, intCol) = "" Then
            Cells(1, intCol) = "=COLUMN()"
        End If
    Next
End Sub