I have a userform that has a Sign In, Sign Out button. and it opens an external excel file that clocks in the current time, saves, then closes the file.
The external file has two columns.
Sign In Sign Out
4/7/2016 10:21 4/10/2016 10:21:51
4/9/2016 10:21
However, sometimes people forget to Sign In or Sign Out on the same day... which ends up the rows dont align accordingly to the right date. i cant seem to figure out the right way to make it become:
Same row only for the same current day, if not. then have to use a new row.
If forget to Sign In, but remembers to Sign Out, then new row. Visa Versa.
Here is my code for my two Sign In, Sign Out buttons:
Private Sub SignIn_Click()
Dim emptyRow As Long
Workbooks.Open Filename:= _
"C:\Users\TNYAUTO\Desktop\Login_Logout database.xlsx"
Windows("Login_Logout database.xlsx").Activate
Worksheets(WorkerList.Value).Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 1).Value = Now()
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
Private Sub SignOut_Click()
Dim emptyRow As Long
Dim emptyRowB As Long
Workbooks.Open Filename:= _
"C:\Users\TNYAUTO\Desktop\Login_Logout database.xlsx"
Windows("Login_Logout database.xlsx").Activate
Worksheets(WorkerList.Value).Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
emptyRowB = WorksheetFunction.CountA(Range("B:B")) + 1
Cells(emptyRowB, 2).Value = Now()
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
ANY HELP IS VERY MUCH APPRECIATED
Bookmarks