①特定のセルから見てデータの入っている一番下の行を取得
(途中う空白有の場合は使えない)
■ 最終行 = Range("B2").End.End(xlDown).Row
②エクセル全体の最終行を取得し、そこから順に上を見ていき、指定した列の
データのある行を取得(途中空白ありもOK)
■ 最終行 = Cells(Rows.Count, 2).End(xlUp).Row
(使用例)
****************************************************************************
Function getLastRow(TargetColumn As Integer) As Integer
getLastRow = Cells(Rows.Count, TargetColumn).End(xlUp).Row
getLastRow = Cells(Rows.Count, TargetColumn).End(xlUp).Row
End Function
****************************************************************************
Sub test()
Dim lastRow As Integer
lastRow = getLastRow(2)
MsgBox lastRow
End Sub
lastRow = getLastRow(2)
MsgBox lastRow
End Sub
****************************************************************************