+ Reply to Thread
Results 1 to 11 of 11

Formula to add rows if cell 2,1 doesn't match 3,1

  1. #1
    Registered User
    Join Date
    06-07-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Formula to add rows if cell 2,1 doesn't match 3,1

    Hi, I would like to write a formula that will insert a blank row every time a cell doesn't match the cell directly above it. Basically I have a list of people who may have multiple rows of data each. I want this formula to add a row between each person.

    For example:
    Sue Smith
    Sue Smith
    Sue Smith...add row
    Tom Jones...add row
    Sally Mae
    Sally Mae
    Sally Mae
    Sally Mae..add Row
    Tammy T
    .......


    I want this formula/if statement to identify the breaks and add a blank row.


    Any tips? Seems so simple but I can't make it happen.

  2. #2
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    I can only think of a macro if you want excel to insert blank. I didn't know any formula that allow excel to insert row/column.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    dluhut is correct, there is no regular formula or function that will insert rows for you, you will need some-one to write some VBA code for you
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    06-07-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    Hi, I'm actually writing a macro. I first was trying it as a loop and that didn't work and then I tried to insert rows after an If statement. I also did a quick if statement to bring back each break in the cells and then tried to insert from there. No luck.

    VBA code would be ideal

  5. #5
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    Any tips? Seems so simple but I can't make it happen.[/QUOTE]

    Try Data > Subtotal > I will let you figure out the rest. If you have any problems post back.

  6. #6
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    assuming your talking about inserting a space in a list that is generated on another worksheet see columns A of the two sheets of this workbook....
    spaced names.xlsx

    If you want to automatically insert it on the same sheet the other users are correct, you will need to do some VBA.

  7. #7
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    I didn't see that you were trying to do this with code. I don't have time to work out the code but if I did I would create a two dimensional array that stores the name with a row number. so NameList(1,1) would be 1 - NameList (1,2) would be "Sue Smith". Namelist(2,1) would equal namelist(1,1)+1 . when it came to Tom jones I would have Name List(4,1)=name List(3,1)+2
    then i would rewrite everything with cell(namelist(1,1),1)=namelist(1,2)

  8. #8
    Registered User
    Join Date
    06-07-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    Thanks for your time...I think you have far...FAR greater skill than I do here! I'm so used to just writing loops or quick formulas that I can't seem to grasp how you would then add rows.... here are the sad ways my mind has tried to figure this out....

    (I really think I can do this without a loop...would prefer to just copy and paste the formula)
    Please Login or Register  to view this content.
    Moderators note: code tags added for you - this time
    Last edited by FDibbins; 06-09-2013 at 03:50 PM.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    flintcs please, according to the forum rules, use code tags when posting VBA code.
    See my notes below on how to add them.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    Simple code

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Formula to add rows if cell 2,1 doesn't match 3,1

    See the link below (with an kind of similar question).

    See # 4 for an VBA solution (in combination with subtotal).


    http://www.excelforum.com/excel-prog...-subtotal.html
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

+ 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