Here is an on-fly example how I would design such sheduler. In my example I
use ISO week definition (a week is always 7 days, the first week of year is
the one with 1st Thursday in it, 1st day of week is Monday)
Create a sheet SetUp
A1="Year"
B1 - enter the year your sheduler is meaned for.
A2="Lunch"
B2 - enter the length of lunchtime in format "h:mm"
Create named ranges (Insert>Name>Define)
Year=$B$1
Lunch=$B$2
D1="Day"
E1="Week"
D2=IF(AND(YEAR(DATE(YearN,1,1+(ROW()-2)*7))=YearN,DATE(YearN,1,1+(ROW()-2)*7
)<=TODAY()),DATE(YearN,1,1+(ROW()-2)*7),"")
copy down for 53 rows
E2
=IF(D2="","",YearN+INT((D2-DATE(YEAR(D2-WEEKDAY(D2-1)+4),1,3)+WEEKDAY(DATE(Y
EAR(D2-WEEKDAY(D2-1)+4),1,3))+5)/7)/100-(WEEKDAY(D2)>3))
E3
=IF(D3="","",YearN+INT((D3-DATE(YEAR(D3-WEEKDAY(D3-1)+4),1,3)+WEEKDAY(DATE(Y
EAR(D3-WEEKDAY(D3-1)+4),1,3))+5)/7)/100
copy E3 down for same range as formula in column D
Hide column D
Create named range
Weeks=OFFSET(SetUp!$E$1,1,,COUNT(SetUp!$E:$E),1)
Create a sheet Employees with table (headers on row 1)
ID, FirstName, LastName, ...
(you can have additional columns in table, but I'll continue with those 3).
The column ID must have unique values.
Create named ranges
Employee=OFFSET(Employees!$A$1,1,,COUNTA(Employees!$A:$A)-1,1)
EmployeesTbl=OFFSET(Employees!$A$1,1,,COUNTA(Employees!$A:$A)-1,3)
Create a sheet Shedule with table
Date, EmployeeID, StartTime, EndTime, Lunch, Name, Week, Hours
For column B (EmployeeID) implement data validation list with source
=Employee
For column E (Lunch) implement data validation list with values "Yes","No"
F2=IF(B2="","",VLOOKUP(B2,EmployeesTbl,2,0)&"
"&VLOOKUP(B2,EmployeesTbl,3,0))
G2=IF(A2="","",YEAR(A2)-(YEAR(A2-4)<YEAR(A2))+INT((A2-DATE(YEAR(A2-WEEKDAY(A
2-1)+4),1,3)+WEEKDAY(DATE(YEAR(A2-WEEKDAY(A2-1)+4),1,3))+5)/7)/100)
H2=IF(OR(C2="",D2=""),"",D2-C2+(D2<C2)-(E2="Yes")*Lunch)
Copy F2:H2 down as much as you thin you need.
Create named ranges
ShedEmpl=OFFSET(Shedule!$B$1,1,,COUNT(Shedule!$A:$A),1)
ShedWeek=OFFSET(Shedule!$G$1,1,,COUNT(Shedule!$A:$A),1)
ShedHours=OFFSET(Shedule!$H$1,1,,COUNT(Shedule!$A:$A),1)
Create a sheet WeeklyRep
A1="Week:"
Implement data validation list to cell B1, with cource
=Weeks
Select a week.
A3="EmployeeID"
B3="EmployeeName"
C3="Hours"
A4=IF(ISERROR(INDEX(Employee,ROW()-3)),"",INDEX(Employee,ROW()-3))
B4=IF(A4="","",VLOOKUP(A4,EmployeesTbl,2,0)&"
"&VLOOKUP(A4,EmployeesTbl,3,0))
C4=IF(A4="","",SUMPRODUCT(--(ShedEmpl=A4),--(ShedWeek=RepWeek),ShedHours))
Format C4 as "[h]:mm"
Copy A4:C4 down at least for so much rows as you have employees.
It's done!
Arvi Laanemets