|
コマンドボタンクリックイベント
Private Sub CommandButton1_Click()
Dim last As Long
Dim i As Long
Dim count As Long
Dim minrow As Long
'捜す最小の行
minrow = 8
'最終行を取得
last = ActiveSheet.Range("A65536").End(xlUp).Row
'データが入力されている場合
If last >= minrow Then
count = 1
'1行づつ捜す
For i = last - 1 To minrow Step -1
'データが入力されている場合
If Range("A" & i) <> "" Then
count = count + 1
End If
Next
End If
'結果の表示
CommandButton1.Caption = count
End Sub
|
|