Option
Explicit
Private
Declare
Sub
Sleep
Lib
"kernel32"
(
ByVal
dwMilliseconds
As
Long
)
Private
blnStop
As
Boolean
Public
Sub
startMeasure()
Dim
strTmp
As
String
strTmp = InputBox(
"Wert Zeitintervall (ms):"
)
If
strTmp = vbNullString
Or
Not
IsNumeric(strTmp)
Then
MsgBox
"Ungültige Eingabe."
, vbExclamation
Exit
Sub
End
If
Dim
lngIntervall
As
Long
lngIntervall =
CLng
(strTmp)
blnStop =
False
Dim
rngValue
As
Range
Dim
wksDaten
As
Worksheet
Set
rngValue = Worksheets(
"Tabelle1"
).Range(
"A1"
)
Set
wksDaten = Worksheets(
"Tabelle2"
)
Do
While
Not
blnStop
Call
addValue(wksDaten, Now, rngValue.Value)
Call
Sleep(lngIntervall)
VBA.DoEvents
Loop
Set
rngValue =
Nothing
Set
wksDaten =
Nothing
End
Sub
Private
Function
addValue(
ByRef
wksDaten
As
Worksheet,
ByVal
datTime
As
Date
,
ByVal
vValue
As
Variant
)
Dim
l
As
Long
l = wksDaten.Cells(wksDaten.Rows.Count, 1).
End
(xlUp).Row + 1
With
wksDaten
.Cells(l, 1) = datTime
.Cells(l, 2) = vValue
End
With
End
Function
Public
Sub
stopMeasure()
blnStop =
True
End
Sub