SubversiveInterloper
New Member
- Joined
- Aug 15, 2019
- Messages
- 12
Workbook: Time Tracker Workbook
The workbook has 45 different modules: 15 modules for Start/Resume, 15 modules for Stop & 15 modules for Reset. The only difference in the 'families' is the Row/Line they refer to (2 thru 16). Each module has been assigned to a 'button' on the corresponding Row/Line.
Start/Resume Module:
Stop Module:
Reset Module:
Just looking to see if there is a cleaner code.
The workbook has 45 different modules: 15 modules for Start/Resume, 15 modules for Stop & 15 modules for Reset. The only difference in the 'families' is the Row/Line they refer to (2 thru 16). Each module has been assigned to a 'button' on the corresponding Row/Line.
Start/Resume Module:
Sub Time_Sheet01_Start_Timer()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Time Sheet")
sh.Range("K2").Value = "Start"
If sh.Range("L2").Value = "" Then
sh.Range("L2").Value = Now
End If
x:
VBA.DoEvents
If sh.Range("K2").Value = "Stop" Then Exit Sub
sh.Range("M2").Value = Now
GoTo x
End Sub
Stop Module:
Sub Time_Sheet01_Stop_Timer()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Time Sheet")
sh.Range("K2").Value = "Stop"
Range("D2").Select
Selection.Copy
Range("E2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("L2:M2").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select
End Sub
Reset Module:
Sub Time_Sheet01_Reset_Timer()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Time Sheet")
Range("E2").Select
ActiveCell.FormulaR1C1 = "0"
Range("A1").Select
End Sub
Just looking to see if there is a cleaner code.