行端、列端、最終行または最終列の行番号、列番号取得

Visual Basic for Applications

Sub Macro()
  Dim Sheet As Integer
  Dim rrr As Integer
  Dim ccc As Integer
  Dim EndRow As Integer
  Dim EndCol As Integer
  Dim FinalRow As Integer
  Dim FinalCol As Integer
  EndRow = Worksheets(sheet).Cells(rrr, ccc).End(xlDown).row
  EndCol = Worksheets(sheet).Cells(rrr, ccc).End(xlToRight).Column
  EndRow = Worksheets(sheet).Cells(rrr, ccc).End(xlUp).row
  EndCol = Worksheets(sheet).Cells(rrr, ccc).End(xlToLeft).Column
  'ワークシート最終行、最終列
  FinalRow=Rows.Count
  FinalCol=Columns.Count
End Sub