+ Reply to Thread
Results 1 to 10 of 10

Find and complete missing times in a huge list

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Find and complete missing times in a huge list

    Hi all,

    I wonder if someone could help me please?

    I have a large list of data (often 30,000+ rows) and I have to make sure that for each month there is a row of data for each name and for each daypart segment. If a daypart segment if missing for a name then I need to add it by inserting a row in the appropiate place, enter the missing data and put 0 as a total figure. Attached is a workbook which I hope will help to understand!

    For example, in the attached workbook the first problem is on row 33 (highlighted in yellow). There is a missing daypart segment, Name2 has no 06:00:00 - 08:59:59 data.

    In my head I was thinking of a code like this:

    Please Login or Register  to view this content.
    There are several problems with this.
    First of all it doesn't work!
    Second I am worried as it is using a loop on several throusand rows and this may take a very long time(?)

    The daypart segments change and the number of daypart segments but are always defined in the next sheet, the heading names are always the same and in the same position and the data is always in the order as the daypart segments in the next sheet.

    This a big problem which I often come across in my new role so would REALLY appreciate any help that can be given!

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Find and complete missing times in a huge list

    Hi Jessica,
    Does the attached help?

    With the attached list you could then add a few fake rows to fill in the missing dates.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Find and complete missing times in a huge list

    Hi Marvin,

    Thanks for your reply.

    My problem is that I have to know which daypart segments, names etc are missing and put in zeros - it is to enter the data into a different system so it all has to be accounted for or else it won't go in.

    I could extend the pivot table so I can find out which dayparts / names are missing etc but it will still be quite manual and time consuming to add these all in.

    Hmm... I'm really stuck!

    Thanks for any advice.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Find and complete missing times in a huge list

    How about putting in year and month and zero's for all the range you need? I've done this before for your kind of problem. See the attached.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Find and complete missing times in a huge list

    Is the attached what you mean? It will be really helpful to see which are missing but to go through and check and then manually write the missing ones out before adding to the list on the left will still be quite time consuming.

    However you have given me another idea.

    If we managed to get a list of months, a list of names and a list of time segments we could build a list of full segments etc ourselves. Then we could use vlookup to add the totals in from the list we have and put zeros in any blank cells?

    I have added another sheet onto the attached. If we have a list of the unique values of the year and month (any missing months don't matter as we have no data for these), unique list of names and unique list of start times, could we have a macro saying something like this?

    a = no. of daypart segments
    b = no. names
    c = no. months

    Copy the list of daypart segments in column D into column I (b*c) times.
    This gives us the dayparts we need.

    Copy name1 from column C into column H (a) times.
    Repeat for all names in column C.
    Copy the list we now have in column H (c) times.
    Now we have all the names and corresponding dayparts.

    Copy month1 from column B into column G (a*b) times.
    Repeat for all names in column B.

    This should give us the complete table that we need so all we have to do is populate it with total figures.
    The ones we have data for we can use v-lookup to match the old table and any which are not found in the old table we can enter zero in.

    What do you think? Is this possible and is it faster than the way I previously suggested do you think?

    Thank you, I really do appreciate it!
    Attached Files Attached Files

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Find and complete missing times in a huge list

    Jessica,
    you have kind of lost me with your last post. I will say that building a full list to fill in holes has been a method I've used in the past. It is pretty easy to build a full list and add it onto the bottom of the real data to "fill in" any possible holes.

    Why is it again that you need the full list? Why aren't holes allowed? These would be my first questions.

    I hope the ideas presented allow you to solve the problem.

  7. #7
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Find and complete missing times in a huge list

    Hi Marvin,

    I understand why you got lost!
    It's a really annoying system we have at work that will not allow any gaps in the data and so we have to have a full list to get it into the system.

    You've given me some great ideas, I will go away with the new ideas you have given me and try to write a macro myself and then come back.

    Thank you!!

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Find and complete missing times in a huge list

    I don't think you need a macro, just a full list of dates. If you need to put names along with the dates then a macro may be needed.

    I'd be looking for some help on the other program's side. Look for a import checkbox that allows non sequential data, or something like that.

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Find and complete missing times in a huge list

    see attachment. It looks like what you wanted to achieve.
    Make sure the following reference is on:
    1. [Alt+F11] - open Visual Basic window
    2. Tools - References - find and tick "Microsoft Activex Data Objects 2.0 Library"
    3. Press "Ok"...
    Run macro "Huge"
    Attached Files Attached Files

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Find and complete missing times in a huge list

    or
    Please Login or Register  to view this content.
    Last edited by snb; 01-05-2011 at 09:36 AM.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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