Excel VBA 質問スレ Part33
レス数が900を超えています。1000を超えると表示できなくなるよ。
0900デフォルトの名無しさん
2014/06/25(水) 21:15:40.33ID:37/MdzoUコード書いてみた
以下のマクロを実行すると変数colで指定した列の最終行が変数rwに入る
例によってシートはWith〜で指定しているので適宜書き換えてください。
Sub test()
Dim col As Long '処理対象列
Dim rw As Long '最終行
Dim er As String '検索するエラー値
Dim rng As Range
With ThisWorkbook.Sheets(1) '処理対象シートの指定
col = 1 '1列目を指定
er = "NaN" 'エラー値”NaN"を設定
rw = .Cells(.Rows.Count, col).End(xlUp).Row
If .Cells(rw, col).Value = er Then
Set rng = .Cells(1, col).Resize(rw).Find(What:=er, after:=.Cells(rw, col), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True, MatchByte:=True)
rw = rng.Row - 1
End If
Set rng = Nothing
End With
End Sub
レス数が900を超えています。1000を超えると表示できなくなるよ。