Why Excel always error and stop during run follow code? [let Cells(2,2)=10]
Code:
Private Sub CommandButton1_Click()
Cells(2, 1) = 0
Call StartData
End Sub
Code:
Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Dim hTimer
Dim BarNo As Integer
Sub CloseData()
On Error Resume Next
Call KillTimer(0, hTimer)
End
Exit Sub
End Sub
Sub StartData()
On Error Resume Next
BarNo = 0
hTimer = SetTimer(0, 0, 1000 / 1, AddressOf Main)
End Sub
Private Sub Main()
On Error Resume Next
BarNo = BarNo + 1
Cells(2, 1) = BarNo
If BarNo > Cells(2, 2) Then
Call CloseData
End
End If
Last edited: