+ Reply to Thread
Results 1 to 5 of 5

How to add rows based on specific columns.

  1. #1
    Registered User
    Join Date
    04-19-2010
    Location
    Miami, Florida
    MS-Off Ver
    Excel 2003
    Posts
    1

    Red face How to add rows based on specific columns.

    Hello all,

    I have a question that I'm not quite sure how to ask. I have an excel document that certain rows dont add up with what is on a few separate columns. For example:

    Let us say Column1 and Column3 are last names.

    | Column1|Column2|Column3|Column4|
    |__alpha_|________|__alpha_ | _______ |
    |__bravo_| _______ |__alpha2| _______ |
    |__charlie| _______ |__bravo | _______ |
    |__Delta_| _______ |__bravo2| _______ |
    |__Ekco_| _______ |__charlie| _______ |
    |__fox___| _______ |__Delta__| _______ |

    Instead of moving column1 down to match what is on column3 I would like to write an If statement(maybe) that can look if column3 does not = column1 then move the row down 1 until it is aligned with column3 so it can look like this.

    Column1|Column2|Column3|Column4|
    |__alpha__| _______ |__alpha__| _______ |
    | _______ | _______ |__alpha2_| _______ |
    |__bravo__| _______ |__bravo__| _______ |
    | _______ | _______ |__bravo2_| _______ |
    |_charlie__| _______ |__charlie_| _______ |
    |__Delta__| _______ |___Delta_| _______ |

    I hope you guys can understand what I'm trying to say and are willing to to take on the challange if not please ask so I can try to explain better.
    Please excuse the underscores I was unable to put spaces without them -Edit
    Last edited by decojones; 04-19-2010 at 09:10 AM.

  2. #2
    Forum Contributor
    Join Date
    09-21-2009
    Location
    Belgium - Mechelen
    MS-Off Ver
    Office 365 - version 2310
    Posts
    278

    Re: How to add rows based on specific columns.

    hi ,
    Attached a small example file that should do the trick.
    Perhaps anyone could modify or simplify it .
    Hope it helps.
    Attached Files Attached Files

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to add rows based on specific columns.

    In case the button gets clicked a second time, add this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    09-21-2009
    Location
    Belgium - Mechelen
    MS-Off Ver
    Office 365 - version 2310
    Posts
    278

    Re: How to add rows based on specific columns.

    JBeaucaire ,
    As i'm always learning something new , could you explain why the change in the code.
    Thanks
    MarMo

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to add rows based on specific columns.

    Try clicking your macro button twice, watch what happens to the data the second time. The change I suggested basically causes "already split" cells (blank in column A) to be skipped the next time around.

+ 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