メモ項目:エクセルのワークシートのとある列の一番下に値が存在する行の位置を行番号で返す関数。

[vb]Function lastrow(ws, chkcol)
‘ ws 対象のワークシート
‘ chkcol チェックするカラム列
If IsObject(ws) = False Then
ws = Worksheets(ws)
End If
If IsNumeric(chkcol) = False Then
chkcol = Val(chkcol)
End If

Dim zz, zx, zy
zz = ws.UsedRange.Address
zx = InStr(1, zz, “:”, vbBinaryCompare)
If zx > 1 Then
zz = Right(zz, Len(zz) – zx)
End If
zy = ws.Range(zz).Row
lastrow = ws.Cells(zy+1, chkcol).End(xlUp).Row
End Function[/vb]

だからどうしたのだ…という程度の中身であるがとりあえず残しておくとしましょう。

実際に使ってみて動作への影響等を調べてから、採用不採用を決定する。