+ Reply to Thread
Results 1 to 9 of 9

Combine rows with duplicate values into separate columns

  1. #1
    Registered User
    Join Date
    08-05-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question Combine rows with duplicate values into separate columns

    I'm trying merge rows that contain similar data using the easiest method possible, but i assume it will require some VBA. If anybody is able to point me in the right direction that would be great.

    An example of what i'm trying to achieve is:

    Please Login or Register  to view this content.
    Turned into:

    Please Login or Register  to view this content.
    EDIT: I've managed to pile together what i need, however it seems to place the non duplicate data into the same column separated by a ";" as opposed to my preferred Name 1 | Name 2 | Name 3 any thoughts on updating this to populate separate cells rather than the same? It also only seems to use logic on two columns as opposed to three i'm requiring.

    Here is the update:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Combine rows with duplicate values into separate columns

    Try adding:
    Please Login or Register  to view this content.
    to the end

  3. #3
    Registered User
    Join Date
    08-05-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine rows with duplicate values into separate columns

    This is awesome! Thank you very much. Only problem is it seems to leave a empty column before and after the 2nd column (aka 'AGE'). Is there anyway to remove these?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Combine rows with duplicate values into separate columns

    you can delete a column with:
    columns(1).delete
    columns(3).delete

  5. #5
    Registered User
    Join Date
    08-05-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine rows with duplicate values into separate columns

    Thank you for this, you beat me to the reply race i already had the answer! Ahh.

    The only final problem i'm having is i'm only able to set one 'columnToMatch'. I need the macro to not only match column 2, but also column 3 (aka 'AREA').

    Here seems to be the problem line:

    EDIT: Linked the wrong line..
    Please Login or Register  to view this content.
    Last edited by itgeekgroup; 03-18-2014 at 09:49 AM.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Combine rows with duplicate values into separate columns

    Hi - I think the code already matches both columns.

  7. #7
    Registered User
    Join Date
    08-05-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine rows with duplicate values into separate columns

    Hmm.. i've just tested it with three columns and it only matches up the 'AGE' column, the 'AREA' column does not come into play. The code just seems to merge the 'AREA' column if the 'AGE' column matches up. I need it only two merge the rows if 'AGE' & 'AREA' match up. I believe i need to create another if statement and another 'columnToMatch' but i'm not sure how.

    Edit: to hopefully simplify what i mean: IF two or more cells in column 'AGE' match themselves, and if two or more cells in the 'AREA' column match themselves then merge rows.
    Last edited by itgeekgroup; 03-18-2014 at 09:59 AM.

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Combine rows with duplicate values into separate columns

    I'd suggest putting in column D:
    =B2&C2
    and then copying down and matching by this column. for example:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-05-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine rows with duplicate values into separate columns

    Seems to work after some playing around, but it hates being moved around. For example if i try to add another column like below, it just go's mental. Is there away to keep this function purely inside VBA? As i also need to run the code multiple times.

    Here is the changes i tried to make to add another fourth column:

    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 08-02-2013, 09:58 PM
  2. Find duplicate values based on 2 separate columns
    By dreich in forum Excel General
    Replies: 1
    Last Post: 01-30-2013, 01:41 AM
  3. Merge duplicate rows and combine data in some of the same columns
    By Ken.runciman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2013, 11:43 PM
  4. Transpose Duplicate Rows to Separate Columns
    By VEL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-26-2012, 01:08 PM
  5. Replies: 8
    Last Post: 04-12-2012, 08:02 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