
Dim fStop As Boolean 'グローバル変数を宣言
Sub Sample()
Dim i As Long
fStop = False
For i = 1 To 500000
DoEvents
If fStop = True Then
MsgBox "処理が中断されました"
Exit For
End If
Next i
End Sub
Private Sub Command1_Click()
fStop = True
End Sub