+ Reply to Thread
Results 1 to 7 of 7

insert a blank row for a missing value of a repeated sequence

  1. #1
    Registered User
    Join Date
    03-28-2014
    Location
    ottawa,canada
    MS-Off Ver
    Excel 2013
    Posts
    4

    insert a blank row for a missing value of a repeated sequence

    Hi,

    I am having issues with organizing some data. In column A i have a series of countries listed in alphabetical order. In column B i have years in a repeated sequence. In column C I have variable data corresponding to each year for each country. For example

    Argentina 1980
    Argentina 1981
    Argentina 1983
    Argentina 1984
    Brazil 1980
    Brazil 1981
    Brazil 1982
    Canada 1980
    Canada 1981
    Canada 1984

    As you can see i have a sequence of years which in my actual data is 1980-2006 for each country but there are some missing years. I would like to insert a blank row for every missing year. Any help is greatly appreciated.

    thanks!

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

    Re: insert a blank row for a missing value of a repeated sequence

    Hi newexcel123 and welcome to the forum,

    Find the attached which has some VBA behind the workbook. It will run down your list and add missing years, to the bottom of the list. When it is done you will need to sort your new data by year and then by country to get the result you want.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-28-2014
    Location
    ottawa,canada
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: insert a blank row for a missing value of a repeated sequence

    Hi MarvinP,

    Thanks a lot for the reply. Unfortunately, when i click on the button it only produces Argentina with the corresponding years of 1980-2006. I have attached a copy of my actual excel data in hopes that it will give you a clear picture of what I mean. You will notice that I have 60 countries in column A spanning between 1980-2006 but some of the years for the countries are missing. I was hoping to insert a blank row where the missing years should be for each country so that in the end I would have an equal amount of rows per country. Any help would be greatly appreciated. Thanks again for the response.
    Attached Files Attached Files

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

    Re: insert a blank row for a missing value of a repeated sequence

    OK - try this one.

    I attacked the problem differently with this. I first built a Pivot Table to get all the different Country names. Then I put years from 1980 to 2006 next to them and copied the range to the bottom of the list in columns A and B. Then Sorted by Year and second by country. This gave some dup Country-Year combinations. Finally a delete duplicates worked as the blank were below all the data years. Hard to explain. See if this works for you. If you do this on other sets of data the VBA code will need cleaning to span better ranges of data.
    Attached Files Attached Files

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: insert a blank row for a missing value of a repeated sequence

    Try this code........
    Please Login or Register  to view this content.
    For detail, see the attached sheet.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Registered User
    Join Date
    03-28-2014
    Location
    ottawa,canada
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: insert a blank row for a missing value of a repeated sequence

    Thanks alot MarvinP! It worked perfectly.

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: insert a blank row for a missing value of a repeated sequence

    I think the code I suggested was not perfect as it was not inserting all the rows properly.
    Please find the attached sheet to see if this works now as per your requirement.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Insert a blank row if number sequence is not complete.
    By califorlina in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2013, 08:59 AM
  2. Excel Macro to find missing dates and insert missing date as blank row
    By JevaMarie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 11:08 AM
  3. [SOLVED] how can i insert a blank row automatically into excel when a number is missing
    By seanduffy1 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-19-2013, 09:23 AM
  4. [SOLVED] Insert row when a row in the sequence is missing
    By mhelmers in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-29-2013, 10:58 AM
  5. [SOLVED] Insert missing rows into repeating number sequence
    By budgie300 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-12-2012, 06:17 PM

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