Hello QuestaTH,
Welcome to the Forum!
I made a few changes to your workbook. The data will now be logged based on the day of the month once the user has entered it. The other change was to provide you with a continuous data and time display. W2 now displays the data and the time in hours, minutes, and seconds. Cell E8 is also updated with this same value automatically.
Here is the macro that updates the "Log" sheet. This in the Worsheet_Change event for "Punch". The attached worksheet has all the changes I mentioned.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim DayRow As Long
Dim Rng As Range
If Target.Cells.Count > 1 Then Exit Sub
Set Rng = Range("E8,G8,I8,L8,N8,Q8,S8")
DayRow = Day(Now()) + 1
If Not Intersect(Target, Rng) Is Nothing Then
Application.EnableEvents = False
For Each Cell In Rng
Worksheets("Log").Cells(DayRow, Cell.Column).Value = Cell.Value
Next Cell
Application.EnableEvents = True
End If
End Sub
Module2 Code to Auto-Update the Date and time
Sub AutoUpdateOn()
Worksheets("Punch").Range("W2") = Now()
Worksheets("Punch").Range("E8") = Now()
Application.OnTime Now() + TimeValue("00:0:01"), "AutoUpdateOn", , True
End Sub
Sub AutoUpdateOff()
On Error Resume Next
Application.OnTime Now(), "AutoUpdateOn", , False
End Sub
Code for ThisWorkbook to Turn the Auto-Update On and Off
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call AutoUpdateOff
End Sub
Private Sub Workbook_Open()
Call AutoUpdateOn
End Sub
Bookmarks