dayjournal memo

Total 975 articles!!

VBA #005 - 値が存在する範囲選択

Yasunori Kirimoto's avatar

画像



値が存在する範囲を選択するメモ。



common.bas


    Dim LastRow As Long
    Dim LastColumn As Long
    Dim AllRange As String

    'シートのレコード数取得
    LastRow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
    'シートの列数取得
    LastColumn = Worksheets("Sheet1").Cells(1, Columns.Count).End(xlToLeft).Column

    '全範囲選択
    AllRange = "A1" & ":" & Split(Cells(LastRow, LastColumn).Address, "$")(1) & LastRow
    Worksheets("Sheet1").Range(AllRange).Select

    MsgBox AllRange


画像



book

Q&A