I have an excel workbook with on sheet for each day (not all consecutive days) , that looks like ExampleSheet1. All sheets contain an empty list events, each with a unique ID and a Name. If the event occurs the time start and end time are noted and Excel calculates the duration of the event (among others).
ExampleSheet1 A B C D E F 1 id name date start end duration 2 100 foo 10.07.2013 16:00 18:30 2,50 3 101 bar 10.07.2013 0,00 4 102 aaa 10.07.2013 12:00 3:30 15,50 5 103 bb 10.07.2013 10:00 12:00 2,00 6 104 ccc 10.07.2013 9:00 11:00 2,00
I want to automate the calculation of a overview, where the duration of each event is summed up per month like in columns C,D and E of ExampleSheet2.
ExampleSheet2 A B C D E 1 id name total in total in total in 2013-07 2013-08 2013-09 2 100 foo 12,00 34,00 ... 3 101 bar 32,00 12,50 .. 4 102 aaa 35,50 123,00 5 103 bb 3,00 5,00 6 104 ccc 8,00 4,50
SUMIF does not work with multiple sheets so my first thought was to call a function like the following from each row in columns C, D and E of ExampleSheet2. But that would result in quite a few iterations and seems to be a very ugly solution.
function counter(targetID As Integer, targetDate As Integer) Integer i = 0 for each worksheet in workbook( for each row( if column1 == targetID; then if month(column3) == targetDate; then i = i + column6 ) ) return i
As I'm not familiar with Excel macros and have to Google&Paste this code together, I'd apprechiate a hint on how to approach this. Thanks.