Skip to content

Instantly share code, notes, and snippets.

@nobrinskii
Last active October 1, 2015 19:58
Show Gist options
  • Save nobrinskii/2048654 to your computer and use it in GitHub Desktop.
Save nobrinskii/2048654 to your computer and use it in GitHub Desktop.
[vba/excel] 指定された列の、入力された最終行番号を取得する
'-------------------------------------------------------------------------------
'指定された列の、入力された最終行番号を取得する
'-------------------------------------------------------------------------------
'【引数】対象シート、対象の列番号
'【戻り値】列番号
'【備考】シートの下端から上方向に検索して、最初に値が入ったセルの行番号を返す。
Private Function GetLastRowNumber(shtTarget As Worksheet, cnTarget As Integer) As Long
Dim rnMax As Long
Dim rnInputedLast As Long
With shtTarget
rnMax = .Cells().Rows.Count
rnInputedLast = .Cells(rnMax, cnTarget).End(xlUp).Row
End With
GetLastRowNumber = rnInputedLast
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment