M
Mr. Loki
I have been tasked with tracking if people fill in their time sheets in on
time. I was able to find the following code to track and copy changes to
rows within a spreadsheet, but I need to modify it to be able to do columns
instead any help would be appreciated.
--------------
Dim myRows() As Long
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRow As Long
Dim myVal As Variant
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo NotDimmed
test = UBound(myRows)
GoTo Dimmed
NotDimmed:
ReDim myRows(1 To 1)
Dimmed:
For i = 1 To UBound(myRows)
If myRows(i) = Target.Row Then Exit Sub
Next i
ReDim Preserve myRows(1 To UBound(myRows) + 1)
myRows(UBound(myRows)) = Target.Row
With Application
.EnableEvents = False
.ScreenUpdating = False
myVal = Target.Value
myRow = Sheets("History Sheet").Cells(Rows.Count, 3).End(xlUp)(2).Row
Intersect(Target.EntireRow, ActiveSheet.UsedRange).Copy _
Sheets("History Sheet").Cells(myRow, 3)
Sheets("History Sheet").Cells(myRow, 2).Value = Now
Sheets("History Sheet").Cells(myRow, 1).Value = .UserName
Target.Value = myVal
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
----------------
As an added question could this be modified so that when an employee changes
their time it records the info in a different spreadsheet instead of in the
active one?
Thanks in advance.
time. I was able to find the following code to track and copy changes to
rows within a spreadsheet, but I need to modify it to be able to do columns
instead any help would be appreciated.
--------------
Dim myRows() As Long
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRow As Long
Dim myVal As Variant
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo NotDimmed
test = UBound(myRows)
GoTo Dimmed
NotDimmed:
ReDim myRows(1 To 1)
Dimmed:
For i = 1 To UBound(myRows)
If myRows(i) = Target.Row Then Exit Sub
Next i
ReDim Preserve myRows(1 To UBound(myRows) + 1)
myRows(UBound(myRows)) = Target.Row
With Application
.EnableEvents = False
.ScreenUpdating = False
myVal = Target.Value
myRow = Sheets("History Sheet").Cells(Rows.Count, 3).End(xlUp)(2).Row
Intersect(Target.EntireRow, ActiveSheet.UsedRange).Copy _
Sheets("History Sheet").Cells(myRow, 3)
Sheets("History Sheet").Cells(myRow, 2).Value = Now
Sheets("History Sheet").Cells(myRow, 1).Value = .UserName
Target.Value = myVal
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
----------------
As an added question could this be modified so that when an employee changes
their time it records the info in a different spreadsheet instead of in the
active one?
Thanks in advance.