Einzufügen : Alt + F11 / Projektexplorer / Deine Tabelle
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E1:E50")) Is Nothing Then Exit Sub
Application.EnableEvents = False
If LCase(Target.Value) = "x" Then
If WorksheetFunction.CountIf(Range("E1:E50"), "x") > 1 Then
Target.ClearContents: MsgBox "Nur 1 Spieler gleichzeitig."
Else
Cells(Target.Row, "A").Interior.Color = vbRed
StartRowTimer Target.Row
End If
Else
Cells(Target.Row, "A").Interior.Pattern = xlNone
CancelRowTimer
End If
Application.EnableEvents = True
End Sub
Einzufügen : Alt + F11 / Einfügen Modul
Public activeRow As Long
Public dueTime As Date
Public scheduled As Boolean
Sub StartRowTimer(ByVal r As Long)
On Error Resume Next
If scheduled Then Application.OnTime dueTime, "RowTimeUp", , False
activeRow = r
dueTime = Now + TimeSerial(0, 50, 0)
scheduled = True
Application.OnTime dueTime, "RowTimeUp"
End Sub
Sub CancelRowTimer()
On Error Resume Next
If scheduled Then Application.OnTime dueTime, "RowTimeUp", , False
scheduled = False
End Sub
Sub RowTimeUp()
With ThisWorkbook.Worksheets("Tabelle1")
If LCase(.Cells(activeRow, "E").Value) = "x" Then
Application.EnableEvents = False
.Cells(activeRow, "E").ClearContents
.Cells(activeRow, "A").Interior.Color = vbGreen
Application.EnableEvents = True
End If
End With
scheduled = False
End Sub