Your management requires, that after each month, you will deliver them the report with your activities, and hours spent working on these in an Excel workbook.
Let's make it as easy as possible, both for your employer and also for you. There is no need to auto-create a new calendar each month from scratch, as the workbook will be ready for subsequent month use automatically.
The Excel workbook also supports leap years (29th February) and months with 30 or 31 days.
Only configure the year, month and the sheet will got recalculated. If the activity is overlaping the weekends, click the button "Cleanup the calendar", and all the content, (excepting the day, weekday name) will be nulled. If the previous month had a less days than the one you are working with, previously hidden row will appear again. Now you can just select the Type and add hours worked and type some description. That is all.
There are 4 tables in the worksheet labeled "Holidays" in the Excel Workbook. Each table is named, so it is possible to mine their data from Excel formulas in other cell to get its values, without specification of worksheet's name.
Note: TODAY in formulas below is written as in last year and current year. It is autocalculated. The right table contains activities to choose from in the dropdown list.
=DATE(YEAR(TODAY())-1;1;1)
=(DOLLAR(("4/"&YEAR(TODAY())-1)/7+MOD(19*MOD(YEAR(TODAY())-1;19)-7;30)*14%;)*7-6)-2
=(DOLLAR(("4/"&YEAR(TODAY())-1)/7+MOD(19*MOD(YEAR(TODAY())-1;19)-7;30)*14%;)*7-6)+1
=DATE(YEAR(TODAY())-1;5;1)
=DATE(YEAR(TODAY())-1;5;8)
=DATE(YEAR(TODAY())-1;7;5)
=DATE(YEAR(TODAY())-1;7;6)
=DATE(YEAR(TODAY())-1;9;28)
=DATE(YEAR(TODAY())-1;10;28)
=DATE(YEAR(TODAY())-1;11;17)
=DATE(YEAR(TODAY())-1;12;24)
=DATE(YEAR(TODAY())-1;12;25)
=DATE(YEAR(TODAY())-1;12;26)
=DATE(YEAR(TODAY());1;1)
=(DOLLAR(("4/"&YEAR(TODAY()))/7+MOD(19*MOD(YEAR(TODAY());19)-7;30)*14%;)*7-6)-2
=(DOLLAR(("4/"&YEAR(TODAY()))/7+MOD(19*MOD(YEAR(TODAY());19)-7;30)*14%;)*7-6)+1
=DATE(YEAR(TODAY());5;1)
=DATE(YEAR(TODAY());5;8)
=DATE(YEAR(TODAY());7;5)
=DATE(YEAR(TODAY());7;6)
=DATE(YEAR(TODAY());9;28)
=DATE(YEAR(TODAY());10;28)
=DATE(YEAR(TODAY());11;17)
=DATE(YEAR(TODAY());12;24)
=DATE(YEAR(TODAY());12;25)
=DATE(YEAR(TODAY());12;26)
01.01.2024 - New Year
15.04.2024 - Eastern Holiday Friday
18.04.2024 - Eastern Holiday Monday
01.05.2024 - Labor Day
08.05.2024 - ČSR Liberation Day
05.07.2024 - Slavic Cyril, Methodius Day
06.07.2024 - Burning Master Jan Hus Day
28.09.2024 - Czech Statehood Day
28.10.2024 - Establishment of independent CZ day
17.11.2024 - Struggle for freedom and democracy day
24.12.2024 - Christmas Eve
25.12.2024 - 1st Christmas Eve
26.12.2024 - 2nd Christamas Eve
01.01.2025 - New Year
07.04.2025 - Eastern Holiday Friday
10.04.2025 - Eastern Holiday Monday
01.05.2025 - Labor Day
08.05.2025 - ČSR Liberation Day
05.07.2025 - Slavic Cyril, Methodius Day
06.07.2025 - Burning Master Jan Hus Day
28.09.2025 - Czech Statehood Day
28.10.2025 - Establishment of independent CZ day
17.11.2025 - Struggle for freedom and democracy day
24.12.2025 - Christmas Eve
25.12.2025 - 1st Christmas Eve
26.12.2025 - 2nd Christamas Eve
Enter the first and last name of the employee, and employee's line manager. Employee's name must be at $E$2 cell, and the position at $F$2. Same applies to employee's line manager, whose name must be at $E$3 and the position in $F$3.
=LEFT(CELL("filename";A1);FIND("[";CELL("filename";A1))-1)
The formula to return the folder containing the opened workbook. It is used later in the macro, as the folder, where the PDF files are to be stored at. Please, make sure, that the value in the cell is containing the last character "\" - because of filesystem usage. If the character is not present, the export of the PDF printout will not be working properly. In Mac OS, the path will be ending by "/".
Employment
State Holiday
Business trip
Sick-Day
An obstacle on employer side
Pass
Caring for a family member
Illness
Holiday
Place activities listed at the left, into the named content (Holidays!J1:J10) the values to choose from when inserting the work evidence information.
To make this list functional, it is required to use the range in "Data Validation" in Evidence sheet, in the Type column. Then copy the cell value to the very last day of the table (31st day at 36th row of the worksheet). The order can be sorted, but Employment is placed as the 1st value, to be easier to use, as most probably, the employment will be used most frequently.
Most of the values are autopopulated on this sheet, excepting the specification of the month, the year, the hours, descriptions and pass note.
In the column "A" is in the day row stored hidden formula, that checks, if the day from current motnh is not listed in the Holidays worksheet. If so, there will be placed into the "A" column the dot character (from the table on the "Holidays" list. This "." (dot character), is used for Conditional Formatting rules, to make the line of the day highlighted, so it is noticable, that such day is State Holiday.
Do not modify the range $A$6:$A$36.
e.g. for A33 cell, following formula is valid (formula is word-wrapped):
=IFERROR(XLOOKUP(DATE(YEAR(TEXT($B33&"/"&$Q$8&"/"&$Q$6;"dd.mm.rrrr"));MONTH(TEXT($B33&"/"&$Q$8&"/"&$Q$6;"dd.mm.rrrr"));DAY(TEXT($B33&"/"&$Q$8&"/"&$Q$6;"dd.mm.rrrr")));StateHolidays[Date];StateHolidays[x];"";0;1);"")
In the column "N" is hidden formula, that returns the Week number of the date, composed by the year, month, and the day at the start of the row. For cases, there will be used the date, that does not exists, the formula returns pseudo number. In my case 666. Also this value is used further (both for condition and also in macro). This time, it is for getting the sum of worked hours during last week.
e.g. for N33 cell, following formula is valid:
=IFERROR(WEEKNUM($B6&"/"&$Q$8&"/"&$Q$6;21);666)
The calculation of the total hours per week is performed based on the week number (hidden by formatting in the column N).
As previously selected the Type of activity in the Work Evidence, these are used for sum operations in a month in total. Now, finally, you will be able to recognize the difference with next generation formulas, instead of formulas containing IF/ELSE, IF/ELSE etc...
Make sure, that the cells containing following formulas are properly formatted ( [hh]:mm ), so it can contain hours in a sum, and not a day format.
Total Worked formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Employment";$N$6:$N$36;"<55")
Pass formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Pass";$N$6:$N$36;"<55")
Holiday formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Holiday";$N$6:$N$36;"<55")
Sick-Day formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Sick-Day";$N$6:$N$36;"<55")
Caring for a family member (CFM) formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Caring for a family member";$N$6:$N$36;"<55")
Obstackle at employer formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"An obstacle on employer side";$N$6:$N$36;"<55")
Business trip formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Business trip";$N$6:$N$36;"<55")
State Holiday formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"State Holiday";$N$6:$N$36;"<55")
Illness formula:
=SUMIFS($M$6:$M$36;MonthlyEvidence[Type];"Illness";$N$6:$N$36;"<55")
Total for employer formula - contains the activities for employer or in benefits (Sick-Day, CMF, ...):
=SUM(SUMIFS($M$6:$M$36;MonthlyEvidence[Type];{"Employment";"Sick-Day";"Pass";"Illness";"Caring for a family member";"Business trip";"An obstacle on employer side";"State Holiday"};$N$6:$N$36;"<55"))
As mentioned before, the code is used to cleanup the monthly calendar (and also to hide/unhide the days, of the month that exists). Another VBA macro is used to select the area and save its content to PDF file. This all, to allow signature of employee as well as employee's manager. The code uses Option Explicit method, so it is easier to recognize, if there is missing a definition of some variable used in the code. Please, find the code below:
Option Explicit
Sub Vymazat()
Dim i As Long, PrvniRadka As Long, PosledniRadka As Long, ColNum As Long
PrvniRadka = 6 'First day row
PosledniRadka = 36 'Row of 31st day in month
i = 0 'Reset of iteration variable value
ColNum = 14 'Column number, where is hidden the formula calculating the week of year number - used for total hours in week calculation
Worksheets("Evidence").Activate 'Select the Evidence sheet
Worksheets("Evidence").Range("D6:K36").ClearContents 'Select and cleanup the range of A4 paper format
For i = PrvniRadka To PosledniRadka '6 to 36 rows iteration
If Cells(i, ColNum).Value <> 666 Then 'If there is a day in same month
Cells(i, ColNum).EntireRow.Hidden = False 'do not hide the day
Else 'for other rows in table, having the value 666 in N column
Range("B" & i, "M" & i).Select 'select the row in table for further formatting - border
Selection.Borders(xlDiagonalDown).LineStyle = xlNone 'horizontal bottom border row - not
Selection.Borders(xlDiagonalUp).LineStyle = xlNone '
horizontal top border row - not
Selection.Borders(xlEdgeLeft).LineStyle = xlNone 'left vertical border - not
With Selection.Borders(xlEdgeTop) 'horizontal top border row - yes
.LineStyle = xlContinuous 'solid
.ThemeColor = 1 'color from the table template
.TintAndShade = 0 'no shading of the color
.Weight = xlThin 'thin border line
End With
With Selection.Borders(xlEdgeBottom) 'horizontal bottom border row - yes
.LineStyle = xlContinuous 'solid
.ThemeColor = 1 'color from the table template
.TintAndShade = 0 'no color shading
.Weight = xlThin 'thin border line
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone 'no right border
With Selection.Borders(xlInsideVertical) 'setup of the vertical selection borders
.LineStyle = xlContinuous 'solid
.ThemeColor = 1 '
color from the table template
.TintAndShade = 0 'no shading of the color
.Weight = xlThin 'thin border line
End With
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone 'no inner borders of selection
Cells(i, ColNum).EntireRow.Hidden = True 'hide whole row
End If
Next i 'Next row
ColNum = 1 'Column A
For i = PrvniRadka To PosledniRadka 'iterace radkou od 6 do 36
If Cells(i, ColNum).Value = "." Then 'pokud je ve sloupci A nalezena tecka
Cells(i, ColNum + 3).Value = "State Holiday" 'tak ve sloupci D zvolit Statni Svatek
End If
Next i 'Dalsi radek
Range("A1").Select 'Vyber bunky A1 po dokonceni behu makra
End Sub
Sub TiskDoPDF()
Dim DochazkaRozsah As Range, PDFFile As String, pdffilename As String, Shex As Object, Cesta As String
On Error GoTo DisplayError 'If Error occurrs display the error dialog
Cesta = "" 'initialization of Path variable
PDFFile = "" 'initialization of PDFFile variable
Application.ScreenUpdating = False 'Display blinking of screens during switching between worksheets
Cesta = Worksheets("Svátky").Range("E19").Value 'Autogenerated Path
pdffilename = Application.WorksheetFunction.Text(Worksheets("Evidence").Range("Q8").Value & "/" & Worksheets("Evidence").Range("Q8").Value & "/" & Worksheets("Evidence").Range("Q6").Value, "yyyy-mm") & "-" & Application.WorksheetFunction.Substitute(Worksheets("Holidays").Range("$E2").Value, " ", "-") & ".pdf" 'resulting filename example: 2023-09-Michal-Kopl.pdf
Worksheets("Evidence").Activate 'Selection of the worksheet for print
Set DochazkaRozsah = Range("A1:N50") 'Range selection to printo into PDF file
PDFFile = Cesta & pdffilename 'path and filename to store in PDF file
DochazkaRozsah.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Set Shex = CreateObject("Shell.Application") 'Create the File System object
Shex.Open (PDFFile) 'Open the created file in application to read the PDF file - eg. to add the signature
Exit Sub 'Quit from the macro, so the error message below is not displayed
DisplayError:
If Err.Number = -2147018887 Then 'It is not possible to write into the used file
MsgBox "And here we have an error number: " & Err.Number & ", with meaning:" & vbCrLf & Err.Description & vbCrLf & "Any chance that the same file is opened in PDF file reader?", vbOKCancel, "Here we have an Error!!!"
Else 'Other error
MsgBox "And here we have an error number: " & Err.Number & ", with menaning:" & vbCrLf & Err.Description, vbOKCancel, "Here we have an error!!!"
End If
End Sub
Excel formulas used in the book uses newest functions from Microsoft 365, as well as IFERROR, efficient formatting of columns without requirements to hide them.
The tables used are defined as Named Areas, so it is more efficient to use their column names in Excel formulas. Named area does not require to use sheet name in formulas instead.
The code used allows to hide the day not existing in the month, or display them again. Also, another VBA macro is, to print the resulting table to PDF for delivery.
Including the space lines, definitions of variables
Will be used in the work evidence printout
Last 2 years of State Holidays, for conditional formatting
Will be used in the work evidence printout
Not only working hours are calculated in total
Will be used in the work evidence printout
There is simply no "Rocket science" required for anyone, who works with the workbook - neither for employees, nor the persons who use the calculated hours spent by the employees in the activities reported.
Do you like the idea, but you are afraid, that you would not be able to compose the workbook from scratch on your own?
Don't be affraid, and simply download the file, and adjust it on your own (headlines, logo, names, positions, State Holidays, Activity types to use, color theme, or anything else you do not like on the source).
Be aware, that workbook contains macros, and your Excel application might recognize it as untrusted. If you decide not to use macros, you can save the workbook into the filetype XLSX (no support of macros), but this will disable adjusting the calendar dimensions, cleanup of the calendar, and also the PDF printouts. Other than that, everything will stay working without any issues.