Home>Templates>Automated Employee Timesheet Template in Excel
Employee Timesheet
Templates

Automated Employee Timesheet Template in Excel

In this article, we have created an automated Employee Timesheet Template in Excel. You can use this template to capture the Employee’s Productive hours. We have used several validations and a few VBA macros to enter the current date and time.

Automated Employee Timesheet Template in Excel

Users can fill time only for today’s date. I will not allow entering the time for past or future dates.

Automated Employee Timesheet Template
Automated Employee Timesheet Template

 

Below are macros that we have used to update the time and clear the sheet.

Option Explicit

Sub Update_Current_Time()

Dim sh As Worksheet
Set sh = ActiveSheet

'''' Validations''''''''''
Dim rng As Range
Set rng = Selection

If Application.WorksheetFunction.CountBlank(rng) <> 1 Then
MsgBox "Incorrect range selection", vbCritical
Exit Sub
End If

If rng.Row < 5 Or rng.Row > 35 Then
MsgBox "Incorrect range selection", vbCritical
Exit Sub
End If

If rng.Column < 2 Or rng.Column > 7 Then
MsgBox "Incorrect range selection", vbCritical
Exit Sub
End If

If sh.Cells(rng.Row, 1).Value <> Int(Now) Then
MsgBox "You can update the time for today only", vbCritical
Exit Sub
End If

'''''''''''''''''''''

sh.Unprotect "1234"
rng.Value = Now
sh.Protect "1234"

End Sub



Sub Clear_sheet()

Dim sh As Worksheet
Set sh = ActiveSheet

sh.Unprotect "1234"
sh.Range("B5:G35").ClearContents
sh.Protect "1234"

End Sub

Visit our YouTube channel to learn step-by-step video tutorials

Youtube.com/@PKAnExcelExpert

Watch the step-by-step video tutorial:

PK
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com