|
グローバル変数に、カウンター変数を追加すればよいのです。全体を再編集して・・
Private MyR As Range
Private Cnt As Integer
Private Sub Worksheet_Activate()
Cnt = 0
Me.CommandButton1.Caption = "待機中"
With Application
.DisplayStatusBar = True
.StatusBar = "●○● 待機中 ○●○"
End With
End Sub
Private Sub Worksheet_Deactivate()
Set MyR = Nothing
With Application
.StatusBar = False
.DisplayStatusBar = False
End With
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If MyR Is Nothing Then Exit Sub
Cnt = Cnt + 1
If Cnt > MyR.Count Then
MsgBox "これ以上、値の転記をすることはできません", 48
Exit Sub
End If
Cancel = True
MyR.Cells(Cnt).Value = Target.Cells(1).Value
End Sub
Private Sub CommandButton1_Click()
With ActiveCell
If .Column > 200 Then Exit Sub
If MyR Is Nothing Then
If MsgBox(.Address(0, 0) & " を基点にしますか", 36) = 6 Then
Cnt = 0
Set MyR = Range(.Cells(1), Cells(.Row, 256))
CommandButton1.Caption = "記録中"
Application.StatusBar = _
"☆☆☆ 記録中 (基点 : " & .Address(0, 0) & ") ☆☆☆"
End If
Else
If MsgBox("記録を終了しますか", 36) = 6 Then
Set MyR = Nothing
CommandButton1.Caption = "停止中"
Application.StatusBar = "★★★ 停止中 ★★★"
End If
End If
End With
End Sub
で、どうでしょーか ?
|
|