Hi All,
I run the following code to capture the current time in certain fields. All that the user does is double clicks a cell to enter the current time. However, if they in error click the field again, then it overwrites the captured time with the current time.
Is it possible to exit the double click event sub if the field already has a time recorded in it?
Here's the code I am using:
Thank you for your help.
I run the following code to capture the current time in certain fields. All that the user does is double clicks a cell to enter the current time. However, if they in error click the field again, then it overwrites the captured time with the current time.
Is it possible to exit the double click event sub if the field already has a time recorded in it?
Here's the code I am using:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim StartCell As String
Dim EndCell As String
'TaskCell = "2"
StartCell = "6"
EndCell = "8"
Breakwatch = "7"
'MinimizeWB = ActiveWorkbook.ActiveSheet("Sheet1").Range("K2")
Select Case ActiveCell.Column
Case StartCell ' Address of start cell
Target.Value = Format(Time, "hh:mm:ss")
Target.Font.Size = 10
Target.Offset(0, 1).Select
Target.Offset(0, 1).Value = "Double Click To Enter Break Time"
Target.Offset(0, 1).Font.Size = 7
'Target.Offset(0, 1).WrapText = True
Target.Offset(0, 2).Value = "Double Click To Enter End Time"
Target.Offset(0, 2).Font.Size = 7
'Target.Offset(0, 2).WrapText = True
Target.Offset(1, -4).Value = "Enter Brief Details on Next Case or Task"
Target.Offset(0, -1).Font.Size = 9
Target.Offset(0, -1).Value = Date
Target.Offset(0, -1).Font.Size = 9
Target.Offset(1, -1).Value = "--SKIP THIS CELL--" _
& " Date Will Get Entered Here Automatically"
Target.Offset(0, -1).WrapText = True
Target.Offset(1, -1).Font.Size = 7
Target.Offset(1, 0).Value = "Double Click To Enter Start Time of Next Task"
Target.Offset(1, 0).Font.Size = 7
Case EndCell ' Address of end cell
Target.Value = Format(Time, "hh:mm:ss")
Target.Font.Size = 10
Target.Offset(1, -6).Select
Case Breakwatch
stopped = False
UserForm1.Show 'vbModeless
If stopped Then
Target.Value = Format(Time - start, "hh:mm:ss")
Target.Offset(0, 1).Select
Target.Font.Size = 10
End If
With Me
UserForm1.TextBox2.Text = Cells(ActiveCell.Row, "B").Value
End With
Case Else
End Select
End Sub
Thank you for your help.