Thank you, Rob for your reply. Following is my code. In my main worksheet is the following start/stop and cleanup code:
Private Sub CommandButton1_Click()
TimerSeconds = 15
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
Range("G6").Select
Selection.ClearContents
Range("C2").Select
Range("F10").Select
Selection.Copy
Sheets("Source").Select
Range("F6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C2").Select
Application.CutCopyMode = False
End Sub
Private Sub CommandButton2_Click()
On Error Resume Next
KillTimer 0&, TimerID
Range("F6").Select
Selection.ClearContents
Range("C2").Select
Range("F10").Select
Selection.Copy
Range("G6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C2").Select
Application.CutCopyMode = False
End Sub
And here this code located in a Module:
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
With ThisWorkbook
.Sheets("Value1").Range("A65536").End(xlUp)(2, 1) = .Sheets("Source").Range("B3")
.Sheets("Value1").Range("A65536").End(xlUp)(1, 3) = .Sheets("Source").Range("B4")
.Sheets("Value1").Range("A65536").End(xlUp)(1, 5) = .Sheets("Source").Range("B5")
.Sheets("Value1").Range("A65536").End(xlUp)(1, 8) = .Sheets("Source").Range("C2")
.Sheets("Value1").Range("A65536").End(xlUp)(1, 10) = .Sheets("Source").Range("B7")
End With
End Sub
There is some other macros/code that is used to delete data and give me a blank worksheet to start new data collection.
As for my question about the time base... duh! We are talking about a counter here. Oops.
I can understand how using a counter to count the number of cell entries on my "Value1" sheet could be used to killtimer. I guess that is what I need to understand. Your help is much appreciated.
Bookmarks