+ Reply to Thread
Results 1 to 6 of 6

Compare and combine duplicates

  1. #1
    Registered User
    Join Date
    07-31-2017
    Location
    Michigan
    MS-Off Ver
    2016
    Posts
    23

    Compare and combine duplicates

    In the example below, I am using the following code (generously provided on this forum) to combine duplicate cases (column A), by filling in the blanks of one duplicate with the value of the other.

    However, some duplicate cases (such as cases 10 and 11 for attribute 2) have different values, but same case number. How can I amend this code to choose the higher one? (and still perform the combine function of the code)

    What I have
    Capture.JPG

    What I'm trying to get
    Capture2.JPG

    Please Login or Register  to view this content.
    Last edited by neulite; 03-14-2018 at 03:02 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Compare and combine duplicates

    Try such code:
    Please Login or Register  to view this content.

    Note that your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Best Regards,

    Kaper

  3. #3
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Compare and combine duplicates

    Kaper's solution is quite a bit more elegant than mine, but i wanted to play around with arrays anyway and came up with the following.

    One note, I believe Kaper's (and the example you provided) only works if the duplicated values occur in subsequent rows. Mine will work even if the duplicated values are out of order. someone more talented than me can probably make this quite a bit cleaner.

    Please Login or Register  to view this content.
    Hope I could help - if your post has been solved don't forget to mark it as such.

    Clicking the * below is a great way to say thanks!

    "Drowning in 10 feet of water isn?t any different than drowning in a million feet. And if you can swim, it doesn?t matter how deep the ocean is. At some level, once you realize you?re in water that?s too deep to stand, you have to have a very different approach," - Joi Ito

  4. #4
    Registered User
    Join Date
    07-31-2017
    Location
    Michigan
    MS-Off Ver
    2016
    Posts
    23

    Re: Compare and combine duplicates

    Thanks for this. I get a "subscript is out of range" error with this for "output(2, UBound(output, 2)) = dedup(2, 1)"

  5. #5
    Valued Forum Contributor
    Join Date
    01-10-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    651

    Re: Compare and combine duplicates

    hmm... i'm not seeing that issue. do you have all your headers in row 1?

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Compare and combine duplicates

    Quote Originally Posted by simarui View Post
    ...I believe Kaper's (and the example you provided) only works if the duplicated values occur in subsequent rows. ...
    As shown in original question on screenshot ( :-( ) attached.
    PS. Code is not mine - it is original code with one minor modification to fulfill request. Personaly, I'd do this probably also with arrays (or may be other data structure) because deleting a lot of randomly positioned rows in the middle of long range is time consuming process.

+ 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. [SOLVED] Combine Duplicates and SUM
    By spiphix in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-24-2016, 04:59 PM
  2. Combine Duplicates and SUM
    By spiphix in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2016, 12:06 AM
  3. [SOLVED] Combine cells and remove duplicates
    By deanblew in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2016, 10:09 AM
  4. Combine Near-Duplicates
    By Moggeth in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2015, 03:28 AM
  5. Replies: 6
    Last Post: 08-31-2011, 10:00 AM
  6. Excel 2007 : Combine information for duplicates
    By Hayden.hr in forum Excel General
    Replies: 1
    Last Post: 10-06-2010, 02:12 PM
  7. [SOLVED] combine row and the delete duplicates
    By bamamike in forum Excel General
    Replies: 2
    Last Post: 09-20-2005, 12:05 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