+ Reply to Thread
Results 1 to 13 of 13

Combine duplicate rows with unique values

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Combine duplicate rows with unique values

    Hi,
    I have a lot of data with same values and some blank cells. Please note that if duplicate rows are there, they contain only unique values. There are no duplicate rows with different values in same column cell. It's either same value or blank. There is no different value. Kindly view the sample file if you feel I'm not explaining well.
    I've got it working with a macro, not quite right...
    I searched everywhere and all I found was combining values those unique values into one cell like A,A.
    Thanks & Regards,
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Combine duplicate rows with unique values

    I put the result in J1 - try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 06-25-2020 at 02:43 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Combine duplicate rows with unique values

    The old fashioned way

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  4. #4
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Combine duplicate rows with unique values

    Hi,
    Thank you so much for your help.
    Update:
    I tested with three sets of data. The second row in the "before" goes to the first row and then also in the third row as a duplicate with same before value (It didn't work only on the second row). All the other rows are consolidated as exactly as needed.

    The before is:

    XXX
    YYY A
    ZZZ
    AAA
    BBB
    YYY A B

    After is:

    YYY A
    XXX
    YYY A B

    Also how to replace it in the same rows instead of J1?
    Last edited by newyorknix; 06-26-2020 at 12:07 PM. Reason: Update

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Combine duplicate rows with unique values

    This is working perfectly! But it is happening right in front of my eyes with a blue waiting symbol and long depending on the data.
    Is there anyway to run it in the background?

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Combine duplicate rows with unique values

    You need to specify which code you are referring to. @JLGWhiz or @xladept

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Combine duplicate rows with unique values

    To replace in the same rows:

    Please Login or Register  to view this content.
    This code should run "in the background".[/COLOR]
    Last edited by xladept; 07-01-2020 at 10:23 AM.

  8. #8
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Combine duplicate rows with unique values

    Hi,
    This is working. Thank you for the help.
    First two rows have duplicate after running macro, I am deleting manually. But its way better than not having anything. I do not know why.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Combine duplicate rows with unique values

    I get no duplication. Here's a better version:

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Combine duplicate rows with unique values

    Try the attached
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Combine duplicate rows with unique values

    @xladept
    Hi,
    I changed it like this and it worked:

    Please Login or Register  to view this content.
    W1 is the column after last data column (the first duplicate got pasted to J1). I changed to A2 & s=1 as first two rows are the only duplicates.
    I verified the data randomly and there is no error anywhere...
    Thank you so much for your kind help, effort and time.

  12. #12
    Registered User
    Join Date
    06-07-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Combine duplicate rows with unique values

    @jindon
    This worked beautifully. Is there anyway to have the result in the same sheet?

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Combine duplicate rows with unique values

    Change red part to any cell reference you want.
    Please Login or Register  to view this content.
    e.g.
    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: 6
    Last Post: 08-02-2019, 02:38 AM
  2. [SOLVED] Combine Duplicate Rows and Sum the Values
    By Neuk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-20-2018, 09:17 AM
  3. Combine/merge duplicate rows but retain unique data
    By Natalie Hanlon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2015, 01:22 PM
  4. Merge Duplicate Rows and Combine Unique Data
    By rickt33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2015, 09:12 PM
  5. Combine rows with duplicate values into separate columns
    By itgeekgroup in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-18-2014, 11:12 AM
  6. Merge Duplicate Rows unique values into single rows for an infinite amount of columns/rows
    By aimeecrystalaid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2013, 08:43 PM
  7. Merge duplicate row cells, but combine unique cell values (Macro)
    By jcornale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2012, 06:40 PM

Tags for this Thread

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