+ Reply to Thread
Results 1 to 5 of 5

Macro to insert rows for missing data

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    4

    Macro to insert rows for missing data

    Hello,

    I am formating hourly weather data and I need to code a macro in order to insert rows where there is missing data. I also need to delete rows where there is multiple weather observations per hour. In the end, there should be exactly one row for every hour of every day in the year, or (24*365) rows total. Any help with this would be wonderful, I have 140 files to format and without the macro it will take weeks.

    I have one of the files attached for reference.


    Thanks,

    JB
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to insert rows for missing data

    Hi

    Here's some of it. Should put in all the additional rows. It will take a while to run, but it does give you status in the status bar. See if it does give you all the extra bits you want, then I'll look at getting unique output.

    Oh, and before you start, select columns A:D and make sure they are formatted as TEXT.

    Please Login or Register  to view this content.
    rylo
    Last edited by rylo; 12-14-2012 at 12:13 AM. Reason: updated code

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to insert rows for missing data

    Hi

    Regarding the multiple entries for the hour, which one(s) are to be deleted? Or should they all be deleted, and a blank row put in as a placeholder?

    rylo

  4. #4
    Registered User
    Join Date
    12-13-2012
    Location
    South Dakota
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Macro to insert rows for missing data

    Hi,

    Regarding the multiple entries per hour, the one that has no temperature observation should be deleted. If both have a temperature observation, it doesn't matter which one is deleted. The blank row as a placeholder is only for missing data.

    Thanks much,
    JB

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Macro to insert rows for missing data

    Hi

    Slight problem with the sub in #2 so try this one along with the deletion of a duplicate item.

    Please Login or Register  to view this content.
    rylo

+ 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