EXCEL VBA 最終行を取得する
'最終行を取得する ' 'Optional ByVal pintCol As Integer 最終行を検索する列番号を指定する。 ' '利用例 ' lngGetLastRow = plngGetLastRow(ActiveSheet, 5) 'URL https://pgbigoroku.hatenablog.com/entry/2022/08/13/155625 '2022/8/13-3 Private Function plngGetLastRow(ByRef shtTarget As Worksheet, _ Optional ByVal pintCol As Integer = 1) As Long Dim lngLastRow As Long 'Excel自体の最終行 With shtTarget lngLastRow = .Cells(Rows.Count, pintCol).Row plngGetLastRow = .Cells(lngLastRow, pintCol).End(xlUp).Row 'D列の最終行を取得 End With End Function