by mrangry » Tue Apr 12, 2022 10:34 am
I'm trying with little success to get a 5 minute timer running when E2 goes "In Play" and resets when "Not in Play". I've found numerous discussions from previous forum threads and I'm still going round in circles. At best I'm a VBA novice - below is some code from a previous thread which I've tried with no joy. Can anyone shed some light....many thanks. Rob
- Code: Select all
Dim timeInPlay As Date
Dim turnedInPlay As Boolean
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
If Range("E2").Value = "In Play" Then
If Not turnedInPlay Then
turnedInPlay = True
timeInPlay = Now
End If
Else
turnedInPlay = False
End If
If turnedInPlay Then Range("T1").Value = DateDiff("s", timeInPlay, Now) Else Range("T1").Value = 0
End If
End Sub