+ Reply to Thread
Results 1 to 10 of 10

Insert rows based on start/end values

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Insert rows based on start/end values

    Hello all - happy almost New Years!
    Working on a little project for an associate, who is tracking completed work items for vendors in various parts of the world. I'm having some trouble getting the data to cooperate, and thought clearer minds might be of some assistance.

    I've attached a data sample, with the data and schedule on sheet 1, and what I want the end result to look like on the "SampleResults" tab.

    The goal is to insert a row for each user (on each day), with a "0" Instance Count, for each hour that falls within the schedule (start hour / end hour) where there are no completed work items logged.

    For example, if User 1 is scheduled to work from 6 to 15, and has completed work items for 6-12 and 14-15, I need a line for hour 13 added for that day. If she has completed work items before or after scheduled hours, they should be left alone, and no lines added before or after. So in the same example, if User 1 had another work item completed at 17, we do not need to add another line for hour 16.

    Hopefully the attachment will make it a little more clear.

    Thanks for any help!
    Attached Files Attached Files
    Last edited by JP Romano; 01-09-2012 at 03:25 PM. Reason: Solved

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Insert rows based on start/end values

    I don't understand the results you have on rows 35-45 compared to rows 47 to 58.
    Both miss a completed work item at 14 hours but you added a row only for the last sample (47-58).
    I think you should have one row inserted between rows 42 and 43. Am I right or did I missed something?
    Regards
    Pierre

  3. #3
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Insert rows based on start/end values

    Ugh... sloppy, sloppy sloppy.
    Yes, you're right... I missed one between 42 and 43... there should be a row for hour 14, with 0 work items. Thanks for pointing that out!

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Insert rows based on start/end values

    Here is a code that should work. At least it does with the sample date you supplied. Also, look at attached file.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Insert rows based on start/end values

    Holy crap, that's awesome! Thank you so much...
    One little monkey wrench that I was unaware of - and if this is a big deal, don't even give it another thought.
    I JUST found out that some of the users may work overnight - so instead of having hours like 9 - 17, they'll have hours like 18-2. Would that be terribly difficult to accommodate?

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Insert rows based on start/end values

    Hi,
    I realised there was a small glitch in the program so I corrected it. It was occuring when there was a gap of more than 1 hour between the last row and the above row.

    I also think I'm able to process night shift data. I programmed a function (Night_S) which is called at the beginning of the program. It modifies the day and time in Sheet1 in order to reduce the day by 1 and add 24 hours to the hours over midnight. This way the program knows it has to process this line as part of the actual user.

    Give it a try and let me know how it performs.
    Pierre

    Please Login or Register  to view this content.
    Pierre
    Attached Files Attached Files
    Last edited by p24leclerc; 01-07-2012 at 11:45 PM.

  7. #7
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Insert rows based on start/end values

    Very sorry for the delay - I hope you don't think I'm not incredibly grateful - was offline this weekend and just now got to this code. Will give it a shot today and let you know how it works out!
    Thank you again for your time and help!

  8. #8
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Insert rows based on start/end values

    I have a slightly different structure, based on user requirements/requests, and am having a little bit of trouble adapting the code (which is a bit over my head, honestly). If it's not too much trouble, and you have the bandwidth, could you please take a look? Your code is in module 4, and I think the problem is that the actual hours worked are in a different place than where your code is looking. I could be wrong, of course!

    Thank you so much for your patience and time - I'll continue to try to figure it out as well, but do appreciate any additional help...
    Attached Files Attached Files

  9. #9
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Insert rows based on start/end values

    Okay, I think I figured it out... solving threat... thank you so much!

  10. #10
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Insert rows based on start/end values

    I also limited the U_sers array to 10 users. If you ever need more than that, just change the DIM statement to fit your needs.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1