Private
Sub
Worksheet_Change(
ByVal
Target
As
Range)
ActiveSheet.Unprotect
If
Range(
"$U$2"
).Value =
"Lauf1"
Then
Range(
"G2:H21"
).Locked =
False
Else
Range(
"G2:H21"
).Locked =
True
End
If
If
Range(
"$U$2"
).Value =
"Lauf2"
Then
Range(
"J2:K21"
).Locked =
False
Else
Range(
"J2:K21"
).Locked =
True
End
If
If
Range(
"$U$2"
).Value =
"Lauf3"
Then
Range(
"M2:N21"
).Locked =
False
Else
Range(
"M2:N21"
).Locked =
True
End
If
If
Range(
"$U$2"
).Value =
"ID"
Then
Range(
"A2:B21"
).Locked =
False
Else
Range(
"A2:B21"
).Locked =
True
End
If
ActiveSheet.Protect
Dim
rngBereich
As
Range, Prüfung, Frage
Set
rngBereich = Union(Range(
"G2:G21"
), Range(
"J2:J21"
), Range(
"M2:M21"
))
If
Not
Intersect(Target, rngBereich)
Is
Nothing
Then
On
Error
Resume
Next
If
CheckBoxStoppuhr.Value =
False
Then
Application.EnableEvents =
False
GoTo
Frage
Application.EnableEvents =
True
End
If
If
Target.Value =
""
Then
Application.EnableEvents =
False
GoTo
Excel
Application.EnableEvents =
True
End
If
If
Target.Value <
"0,001"
Then
Application.EnableEvents =
False
Target.Value = Target.Value * 86400
Application.EnableEvents =
True
End
If
Excel:
AppActivate
"Microsoft Excel"
Frage:
Frage = MsgBox(
"War der Lauf gültig?"
, vbYesNo + vbMsgBoxSetForeground,
"Gültigkeitsprüffung"
)
If
Frage = vbNo
Then
Application.EnableEvents =
False
Target.Offset(0, 1) =
"x"
Application.EnableEvents =
True
Else
Application.EnableEvents =
False
Target.Offset(0, 1) =
""
Application.EnableEvents =
True
End
If
If
CheckBoxStoppuhr.Value =
True
Then
Application.EnableEvents =
False
AppActivate
"StoppUhr"
Application.EnableEvents =
True
End
If
End
If
End
Sub