+ Reply to Thread
Results 1 to 5 of 5

Fill in missing data

  1. #1
    Registered User
    Join Date
    06-11-2010
    Location
    grinnell, iowa
    MS-Off Ver
    Excel 2007
    Posts
    79

    Fill in missing data

    Hey,
    I have a dataset filled from A1 to E35383. A contains dates, but only the first of each month, and it switches months every few thousand rows. There is a certain term in column B, let's say "Pretzels," that appears once in about 4 of these months in non-consecutive months. In other words, I have data for Pretzels for May, January, and December, but not any of the other months. I need to add in a line for Pretzels for the months where it is missing, and just have the corresponding C, D, and E cells say "0" to denote that there isn't data for Pretzels for that month. Here's what I've been thinking for the code so far, but it seems very inefficient and obviously it doesn't work, but it might help you get the idea for what I'm trying to accomplish:

    Please Login or Register  to view this content.
    If this is the most efficient way to go, then I'd need help getting the missingdates = totaldates - founddates piece to work, I think. If anyone has another solution (which I'm sure exists), please throw it out there. Thanks for the help.

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

    Re: Fill in missing data

    Take care that the last cell of the usedrange in column A has some value (if the last row in column B is 1277, then put a space in cell A1278).
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-11-2010
    Location
    grinnell, iowa
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: Fill in missing data

    snb,
    This looks very helpful, but I'm not familiar enough with the code you're using to know what to change for my worksheet (other than changing "string" to "pretzel," presumably). Can you add comments to explain how the code works so that I can go through it and figure out where it's going wrong? Thanks for the help.

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

    Re: Fill in missing data

    I 'avn't got the faintest.. of your sheet, so use F8 in the VBEditor.

    columns(1) = column A
    columns(2) = column B

  5. #5
    Registered User
    Join Date
    06-11-2010
    Location
    grinnell, iowa
    MS-Off Ver
    Excel 2007
    Posts
    79

    Re: Fill in missing data

    Your code runs without an error message, it simply doesn't create any new rows. If you explain how your code is supposed to work, I might be able to figure out what's going on. Sorry I can't post up my worksheet, but an explanation of the code should help out a lot.

+ 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