Private
Sub
Worksheet_Change(
ByVal
Target
As
Range)
Dim
dblValue
As
Double
Dim
dblMs
As
Double
, dblSec
As
Double
, dblMin
As
Double
, dblHour
As
Double
Dim
rngTime
As
Range
Set
rngTime = Intersect(Range(ThisWorkbook.Names(
"Uhrzeiten"
).RefersTo), Target)
If
Not
rngTime
Is
Nothing
Then
If
IsNumeric(rngTime.Value)
And
Not
Left(rngTime.Formula, 1) =
"="
Then
dblValue = rngTime.Value
dblMs = dblValue - (Int(dblValue / 1000) * 1000)
dblValue = (dblValue - dblMs) / 1000
dblSec = dblValue - (Int(dblValue / 100) * 100)
dblValue = (dblValue - dblSec) / 100
dblMin = dblValue - (Int(dblValue / 100) * 100)
dblValue = (dblValue - dblMin) / 100
dblHour = dblValue
Application.EnableEvents =
False
With
rngTime
.Formula =
"=TimeValue("
""
& dblHour &
":"
& dblMin &
":"
& dblSec &
","
& dblMs &
""
")"
.NumberFormat =
"hh:mm:ss.000"
End
With
Application.EnableEvents =
True
End
If
End
If
End
Sub