Hi again, sorry for the delay in replying.

Originally Posted by
lizzardking
I see, capitals for AM PM (blush)
am/pm are normally written in lower case (in UK & International English - not sure about American), so you were right, but unfortunately Microsoft haven't given us this option.

Originally Posted by
lizzardking
I never would have got that (head in shame)
Don't worry about it - this is how we all learned!
On to the problem at hand...
Unfortunately, the way your calendar is laid out makes it a bit complicated to get monthly totals*, as we're effectively dealing with 32 different tables. We need to get all of that info into a table which looks up each day, allowing the hours to then be summed.
* I understand why you've done it this way - for printing - this is an observation not a criticism.
I've therefore created a table to the right of your calendar which looks up the times selected in the calendar and converts these to hours for each day. The formulae in the table use MATCH (to check for the correct name in each section of the calendar) combined with INDEX-MATCH (to look up the correct start and end times). These are put into your formula to subtract the lunch hour and return the number of hours worked - i.e. it's still the same 'IF name matches, subtract start time from end time, times 24 for hours, subtract lunch hour'.
The final formula (for the first name, on the first day) is:
The various bits of the formula work like this:IF(ISERROR(<formula>),0,<formula>)
I'm on 2003 at work, so this works like IFERROR to return 0 if the formula would otherwise return an error. You could use IFERROR instead - I just can't at the mo.MATCH(($AJ7,$E$8:$E$13,0)
This checks if the name ('Helen') appears in the list of names on the first Monday.INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))
and
INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0))
These look up 'Helen' in the list of names on the first Monday and return the end time & start time. These are combined into:(SUM(INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))-INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0)))*24)-1
which turns the number into hours and subtracts the lunch hour.
The final formula was then copied down the 'Mon 1' column of the table. It was then amended for subsequent columns (it can't just be 'dragged' across as each day in the calendar is four columns and the rows change when you move down in the calendar).
The final column of the table (BQ) then sums the hours for each member of staff for the month. This list of totals is named 'Total_hours_for_month'. Your 'Hours' section below the calendar then looks up this column for the number of hours for each name. I've coloured both these sections blue so you can see the connection quickly.
I see you have an 'Hours' section beside the 'List of Tasks' as well. If you want this to be done, you can copy the table and amend it to deal with tasks instead by putting Task names in the first column, then referring to $B8:$B13,...etc instead of $E8:$E13,...etc.
The formulae assuming a one-hour lunchbreak will only give the correct number of hours if the staff always come in before lunch and leave after lunch. If you want to deal with staff working only a morning or only an afternoon, you can check that the start time is in the morning (up to 12noon) and the end time in the afternoon (1pm onwards) by doing this:
Replace(SUM(INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))-INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0)))*24)-1
withIF(AND(INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))>=(13/24),INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0))<=0.5),(SUM(INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))-INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0)))*24)-1,SUM(INDEX($D$8:$D$13,MATCH($AJ7,$E$8:$E$13,0))-INDEX($C$8:$C$13,MATCH($AJ7,$E$8:$E$13,0)))*24)
This is for the first formula in the Names/Days table (Helen/Mon 1) - you'd need to copy/amend it into the rest of the table. If you're content that this won't happen, then don't worry about it.
Finally, a few 'worksheet management' points:
(1) You had six rows for positions/names in the first week, but only five for the rest of the month - I've inserted extra rows to make this five throughout (it made the find/replace easier so I hope you don't mind).
(2) The small labels in blue italics are Range Names which helped me remember what was named and how it was named - feel free to delete these.
(3) I've put borders round the named ranges as well, so that I could see where they started and ended - again, feel free to get rid of these borders.
Lastly - here's the file: RosterCal2 monthly hours totalled.xlsx
I hope that's all helpful.
Regards,
Aardigspook
If your problem is solved, please go to 'Thread Tools' on your first post and 'Mark Thread as Solved'.
You don't need to give me rep if I helped, but thanks are appreciated.
Bookmarks