Comparing 2 columns and concatenating the Data of adjacent column

  • I have data in Sheet1 with 4 columns: ID, Sequence, DOS, and Note.


    My code creates a duplicate sheet and removes columns B and D, keeping only columns A and C. Then, it removes any duplicate entries based on the values in columns A and C.


    Next, the code looks up data from Sheet1 using columns A and C as the key, and concatenates the values in column D. It then pastes this data into column C of the duplicate sheet.


    I would like to add a few more lines of code to include column 2, Sequence, so that the data is copied based on ascending order of sequence values. However, I'm having difficulty implementing this and would appreciate any assistance.



  • Go to Best Answer
  • Hi,


    If my understanding is correct, basically you only need to sort your database By ID and By Sequence before your macro ConvertRawData in order to get your expected output.


    Hope this will help :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Good to hear you can get your expected result :)


    As far as processing speed is concerned, an immediate improvement can be achieved with following instructions at the very top of your macro :

    Code
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual


    How large is your actual database ? The only potentially "slow" section would be the Loop to generate the Merged Notes ;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Using ScreenUpdating and Calculation can save time, but they may not be effective in all situations.


    The amount of data being processed varies from week to week, but it will never be less than 50,000 rows.

    • New
    • Best Answer

    Try:

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Mumps


    Thanks for suggesting a Dictionary solution for large data sets :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Glad to have been able to help. :)

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • mythu

    Selected a post as the best answer.
  • mythu

    Selected a post as the best answer.
  • One more favor is it possible to convert the result into below format with dates and brackets


    IDNote
    005-31-2018: (more better)
    102-28-2006: (Look at the staidum next to abal road)
    303-08-2010: (Careem is away and will be reached late)
    712-26-2007: (the code is running but slow)
    1407-25-2008: (Chapter 7 is more complicated) 09-02-2021: (Nothing is more curious) 08-23-2022: (Management is decided to leave)
    1611-03-2006: (None) 12-22-2006: (1 2 3 4 5)
    2506-23-2007: (1 and 2 and 3 and 4 and 5 and 6 and A B C)
    2612-09-2004: (Nothing special for the day)
    3612-04-2009: (John woh) 07-23-2010: (Listen) 07-29-2010: (Kim Antonio)
    3709-22-2006: (1 2 3) 12-27-2006: (85426351) 06-26-2007: (A1 B2 C3 D4) 07-11-2007: (Lines) 09-19-2007: (Products)
  • Post by Archie5287 ().

    This post was deleted by rory ().
  • Try:

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Thank you its working fine but there is one problem that is it should concatenate the Dates and Notes for unique ID. Right now code is concatenating based on ID's and Dates:


    For Example for Id# 14 it should concatenate like this in ascending order

    ID Concatenate Result
    14 7/25/2008: (Chapter 7 is more complicated) 8/23/2022: (Management is decided to leave) 9/2/2021: (Nothing is more curious)
  • Quote

    7/25/2008: (Chapter 7 is more complicated) 8/23/2022: (Management is decided to leave) 9/2/2021: (Nothing is more curious)

    I'm sorry but I don't follow. Do you want to combine the notes for each unique ID in the same cell? Please clarify in detail.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • I would like to merging data that contains repeating ID's, specifically in cases where a single ID appears multiple times with unique DOS (Date of Service) entries. My objective is to consolidate the notes associated with each unique DOS entry into a single cell, similar to the example I provided earlier.


    So all notes and thier respective dates will be merged for each unique ID


    IDConcatenate Result
    147/25/2008: (Chapter 7 is more complicated) 8/23/2022: (Management is decided to leave) 9/2/2021: (Nothing is more curious)
  • Could you please post a revised copy of your file which contains your expected results.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!