View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Valiant Valiant is offline
external usenet poster
 
Posts: 12
Default Issues with time clock

Thanks Bob and John, both of your advices helped a lot and I now have it
working the way I wanted it to. I appreciate the help.

"Bob Phillips" wrote:

Sub TimeStampStart()
Const TimeStampColumn As String = "D"
Const PWORD As String = ""
ActiveSheet.Unprotect PWORD
Dim X As Long
Dim LastUsedRow As Long
With ActiveSheet
LastUsedRow = .Cells(Rows.Count, TimeStampColumn).End(xlUp).Row
.Cells(LastUsedRow - (.Cells(LastUsedRow, TimeStampColumn). _
Value < ""), TimeStampColumn).Value = Now
End With

Const DateStampColumn As String = "A"
Dim Y As Long
Dim LastUnusedRow As Long
With ActiveSheet
LastUnusedRow = .Cells(Rows.Count, DateStampColumn).End(xlUp).Row
If .Cells(LastUnusedRow, DateStampColumn).Value < "" Then
LastUnusedRow = LastUnusedRow + 1
End If
If .Cells(LastUnusedRow - 1, TimeStampColumn).Value = "" Then
MsgBox "previous entry not clocked out"
Else
.Cells(LastUnusedRow, DateStampColumn).Value = Date
.Cells(LastUnusedRow, TimeStampColumn).Value = Time
End If
End With
'ActiveSheet.Protect PWORD
ActiveWorkbook.Save

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"valiant" wrote in message
...
I was hoping I could get some help on a time clock like function I had
created previously with some help from this site. As it currently stands,
I
have a working time clock-like macro for use in an excel program. The
current code is:

Sub TimeStampStart()
Const TimeStampColumn As String = "D"
Const PWORD As String = ""
ActiveSheet.Unprotect PWORD
Dim X As Long
Dim LastUsedRow As Long
With ActiveSheet
LastUsedRow = .Cells(Rows.Count, TimeStampColumn).End(xlUp).Row
.Cells(LastUsedRow - (.Cells(LastUsedRow, TimeStampColumn). _
Value < ""), TimeStampColumn).Value = Now
End With

Const DateStampColumn As String = "A"
Dim Y As Long
Dim LastUnusedRow As Long
With ActiveSheet
LastUnusedRow = .Cells(Rows.Count, DateStampColumn).End(xlUp).Row
If .Cells(LastUnusedRow, DateStampColumn).Value < "" Then
LastUnusedRow = LastUnusedRow + 1
End If
.Cells(LastUnusedRow, DateStampColumn).Value = Date
.Cells(LastUnusedRow, TimeStampColumn).Value = Time
End With
ActiveSheet.Protect PWORD
ActiveWorkbook.Save

End Sub

The current issue I am having is that a potential employee could clock
into
a new job (if they changed to a different project) and forget to clock out
of
their old job. I am wondering if there is any way that when an employee
runs
the above macro, it could check to see if the previous row had an entry
filled in for column F, the time out column. Any help would be
appreciated,
thank you.

P.S. I posted a similar message on Tuesday and hadn't received a response
so I thought I should post again because it may have been missed. I
apologize if this is improper etiquette.