The problem: I am developing a scheduling application using excel and am absolutely beside myself on how to compare two worksheets without having an unGodly long macro recursively looping through both sheets.
The details: I do contract security. I have two worksheets. 1 is a "master" schedule. It lays out scheduled shift times for the week according to contract requirements under ideal conditions. The second sheet is the actual working schedule. Due to extra coverage outside the contract, understaffing and callouts, the master schedule is not always followed. I need to compare shifts on the actual schedule to contract requirements to make sure shifts are not skipped. The issue is that I cannot simply compare times. If the master schedule has 3 shifts (0000-0800, 0800-1600, and 1600-2359) on a given day, and the actual schedule has 2 shifts (0000-1200, 1200-2359). The shifts do not match, but in reality the shifts are in fact covered. Add to that, the fact that reading back and forth from a worksheet to vba is a nightmare on processing time and the fact that shifts won't always be in chronological sequence, every method I can think of is not efficient.
Possible Solutions:
I'm currently passing the master worksheet in as a range converted to an array and processing the array to generate a scripting.dictionary object. The use of the keys makes lookup comparison better. I've considered making a dictionary of dictionaries to break up days with shifts and shift time respectively (but this doesn't address the times not matching). I would have to recursively loop back through the dictionaries to find times. Copying the shifts to another worksheet to sort it may help, but the time to write and read it could prove to take even longer than looping unsorted. I've considered making a copy of the dictionary for compare reasons and deleting them as times are found on the actual (sort of a checkoff list) and returning what's left as holes in shifts, but still this doesn't address times not matching.
The final: what alternative ways can be done to catalog a master schedule in memory and compare it to a working schedule that is efficient even when times overlap?
DNA Tech Solutions
Bookmarks