+ Reply to Thread
Results 1 to 15 of 15

Removing duplicates from a list, while also adding frequencies

  1. #1
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Removing duplicates from a list, while also adding frequencies

    Hello everyone,

    I have run into a problem that I have a hard time figuring out myself. I was hoping that maybe someone here could help me out. For scientific research on the repertoire of immune cells, I have a list with species, and the frequency of such a species. This data is then analysed by a computer program that models diversity in this repertoire. However, I have run into a problem with the way my data is organised. The data is as such:

    Species Frequency
    A 15
    B 10
    C 12
    A 5

    However, the program needs input as such:

    Species Frequency
    A 20
    B 10
    C 12

    As you can see, the duplicate A has been removed and added to the first instance of A found. Is there anyway I could easily do this with excel?
    The lists I have each contain about 60.000 rows, so I hope to find something that can be automated and does not take to much computing power.

    Does anyone have a solution or a tip for this problem?
    Attached Files Attached Files
    Last edited by SiebeB; 11-12-2018 at 09:39 AM. Reason: Added sample workbook

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Removing duplicates from a list, while also adding frequencies

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

  3. #3
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Thank you for the tip, i will add a sample workbook in a bit

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Removing duplicates from a list, while also adding frequencies

    Use Pivot Table.

  5. #5
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Quote Originally Posted by Phuocam View Post
    Use Pivot Table.
    Thanks for the suggestion, but could you please elaborate? I know I could make a pivot table and add the frequencies manually, but this would involving analysing 60 samples of about 60.000 rows with manual techniques. Is this what you mean, or am I missing something?

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Removing duplicates from a list, while also adding frequencies

    See attached file.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Quote Originally Posted by Phuocam View Post
    See attached file.
    Super, thank you! I will let you know if this works with bigger datasets.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Removing duplicates from a list, while also adding frequencies

    I have a simple clip of how to use a pivot table for your data set.

    https://www.screencast.com/t/caRP9PMo0

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Removing duplicates from a list, while also adding frequencies

    VBA solution.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  10. #10
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Thank you for all your suggestions. The solution with the pivot tables is working, however it is still quite a bit of work to create these pivot tables. I would prefer using the VBA solution. However, I am a bit new in VBA, and cant get it to work. When i try to run this VBA code I get a "object required" error. When I use debug mode, it seems to be this line that causes problems:
    sn = Blad1.Cells(1).CurrentRegion.Value
    Last edited by SiebeB; 11-12-2018 at 01:33 PM. Reason: addition

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Removing duplicates from a list, while also adding frequencies

    That line means your data starts in A1.
    I've put the code in your example sheet so you can see it works.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Quote Originally Posted by bakerman2 View Post
    That line means your data starts in A1.
    I've put the code in your example sheet so you can see it works.
    Thank you for your effort. However, the code is not doing anything on my pc. Could it be different excel versions?

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Removing duplicates from a list, while also adding frequencies

    Quote Originally Posted by SiebeB View Post
    Thank you for your effort. However, the code is not doing anything on my pc. Could it be different excel versions?
    The results are on the other sheet

  14. #14
    Registered User
    Join Date
    11-12-2018
    Location
    Amsterdam
    MS-Off Ver
    office 365
    Posts
    9

    Re: Removing duplicates from a list, while also adding frequencies

    Thank you everyone. I solved the problem with your help. In the end I ended up using a macro based on the pivot table solution that I was shown here. The code for everyone who might make use of it:

    Please Login or Register  to view this content.

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Removing duplicates from a list, while also adding frequencies

    Thanks for feedback and rep+.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Removing Duplicates and adding special characters
    By dawsonsoo in forum Excel General
    Replies: 7
    Last Post: 10-12-2011, 02:49 PM
  2. Removing Duplicates from a list
    By JohnGuts in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-06-2005, 05:05 PM
  3. [SOLVED] Removing Duplicates from a list
    By Peo Sjoblom in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 02:05 PM
  4. Removing Duplicates from a list
    By JohnGuts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  5. Removing Duplicates from a list
    By JohnGuts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  6. [SOLVED] Removing Duplicates from a list
    By JohnGuts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. adding into combo box and removing duplicates
    By Abhay Sanan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-01-2005, 01: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