+ Reply to Thread
Results 1 to 39 of 39

Creating a unique list from a list of duplicates

  1. #1
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Creating a unique list from a list of duplicates

    Hey Guys,

    I have a problem in Excel that I really need help with. I have two sheets, the first sheet has a column with duplicates (all my columns have headers). In my second sheet I would to have the list, generated from the column in the first sheet, but a unique list. I have tried different formulas, and nothing works! I am posting it here under Macros and VBAs, because perhaps a Macro would be a better solution, unfortunately I have little experience with Excel macro's, though I have some experience with VBA in Access. A solution in the form of Macro or a Formula would both be helpful!

    Please help!

    Many thanks!

    S

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Creating a unique list from a list of duplicates

    not sure understanding question properly
    you just want a copy of a sheet but remove duplicate rows based from a column ?

  3. #3
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: Creating a unique list from a list of duplicates

    will you upload a sample file.......in which there are some problem data and manual solution data.......


    Regards
    CA Mahaveer Somani

  4. #4
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Basically the first sheet, lets call it 'Pre - General Training' has the following data:

    Name of Event
    Training the trainers
    Training the trainers
    Policy Update Training
    Policy Update Training
    Policy Update Training
    Policy Update Training
    Training Course on MIS
    Training Course on MIS
    Training Session on Cloud Computing
    Training Session on Cloud Computing
    Training Session on Cloud Computing
    Training Session on Cloud Computing
    Training Session on Cloud Computing

    I basically want a column in the second sheet, lets call it 'Need for further training' (second sheet is in the same excel file), to contain a unique list from the above column, for example:

    Name of Event
    Training the trainers
    Policy Update Training
    Training Course on MIS
    Training Session on Cloud Computing

    Hopefully this explains it, thanks in advance guys!


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

    Re: Creating a unique list from a list of duplicates

    1) copy "Name of Event" column
    2) Paste on the other sheet
    3) go to [Data] - [RemoveDuplicate]

    Should do.

  6. #6
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Quote Originally Posted by jindon View Post
    1) copy "Name of Event" column
    2) Paste on the other sheet
    3) go to [Data] - [RemoveDuplicate]

    Should do.
    This will not work as the first sheet will be updated regularly and thus I need the second sheet to be dynamic and not static.

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

    Re: Creating a unique list from a list of duplicates

    Then make it as an event driven code...

    To a sheet module

    Please Login or Register  to view this content.

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    Try this,

    Please Login or Register  to view this content.
    Jindon , that code won't remove all duplicates.
    Last edited by JapanDave; 04-23-2013 at 01:45 AM.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Creating a unique list from a list of duplicates

    not sure if it helps you, just try it
    Please Login or Register  to view this content.
    hi Dave, sorry about that, posted without to refresh the page....sorry!
    Last edited by john55; 04-23-2013 at 01:53 AM.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  10. #10
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Thanks guys! JapanDave, I'm very very fresh to excel macros, where exactly do I input this code. (Sorry about such a silly question). In addition to this the code is referring to the sheet 'Need for Further Training', but I can see its not referring to the first sheet 'Pre - General Training', why is that? Should it refer to 'Pre - General Training' , if that's where the duplicates are?

  11. #11
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Thanks for your solution as well john, but is there a way I can avoid using a button, or is it the best way to go abouts this problem?

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Creating a unique list from a list of duplicates

    yeap, goto vb editor, insert a module and copy/paste this...then run it from main meniu, (choose it from that window)
    Please Login or Register  to view this content.

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

    Re: Creating a unique list from a list of duplicates

    As you select "Need for further training" sheet, it updates
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Thanks again John, I'm trying to run the macro but it keeps giving me the runtime error '9' (Sheets("Pre - General Training") = <Subscript Out of Range>

  15. #15
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    @ssu, in a standard module in the VB editor. If you like it can be made to run automatically.

    How John, long time no speak!

  16. #16
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    My thanks to all three of you. Im trying the codes now, but I think because of my lack of experience in Excel Macros, I maybe making some basic mistakes. I'm currently trying John's code, but it keeps coming up with errors.

    This is my code right now (sheet one is actually called 'Pre - Training Assessme', its not a typo and the name can't be changed):

    Sub DuplicateDelete()
    'delete duplicates and copy to sheet2
    Application.ScreenUpdating = 0
    With Sheets("Pre - General Training Assessme")
    Dim X As Long
    Dim LastRow As Long

    LastRow = Range("a65536").End(xlUp).Row
    For X = LastRow To 1 Step -1
    If Application.WorksheetFunction.CountIf(Range("a2:a" & X), Range("a" & X).Text) > 1 Then
    Range("a" & X).EntireRow.Delete
    End If
    Next X
    End With
    Sheets("Pre - General Training Assessme").Range(Range("a2"), Range("a2").End(xlDown)).Copy Sheets("Need for Further Training").Range("A2") 'change Sheet1 or Sheet2 for your needs
    Application.ScreenUpdating = 1
    End Sub

    There is an error 1004 (Application or Object Defined Error) showing up on the line:
    Sheets("Pre - General Training Assessme").Range(Range("a2"), Range("a2").End(xlDown)).Copy Sheets("Need for Further Training").Range("A2") 'change Sheet1 or Sheet2 for your needs


  17. #17
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Creating a unique list from a list of duplicates

    hi
    it works for me (copy exactly the name of yr sheet, take care of those spaces!!!!)
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by john55; 04-23-2013 at 02:46 AM.

  18. #18
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    Try the workbook,
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Ok, let me try

  20. #20
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    John, even your sheet is giving me the same error. Maybe my version is different from yours? My version is definitely Excel 2007.

    The solution that is currently working for me is Jindon's test.xlms (Thanks a bunch Jindon ), but for the sake of learning I want to get my head around your solution as well John. Any ideas how I can rectify it?
    Last edited by ssu; 04-23-2013 at 03:06 AM.

  21. #21
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Creating a unique list from a list of duplicates

    or, copy/paste in vb editor, select sheet "need for...", from left window select workseet, right window select Activate
    Please Login or Register  to view this content.
    Last edited by john55; 04-23-2013 at 03:09 AM.

  22. #22
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    Quote Originally Posted by ssu View Post

    The solution that is currently working for me is Jindon's test.xlms (Thanks a bunch Jindon ), but for the sake of learning I want to get my head around your solution as well John. Any ideas how I can rectify it?
    I don't see how it is,
    Maybe if he fixed his code to this,
    Please Login or Register  to view this content.
    Instead of this,

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    @Dave, I just checked the code and yes Jindon made the changes you are suggesting. Are there any disadvantages of using this code as the solution? (I ask to increase my understanding of this code, )
    @John, The code is not generating an error anymore, however its also not removing duplicates, its just as if its copying and pasting the entire column :S.

  24. #24
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    The code I am using is more efficient, for an entire single column in Excel 2010 ,using Remove Duplicates is about 0.3 seconds slower @ 1.527 seconds, using an array in this instance is @ 1.201 seconds. Not a big deal if you don't have a lot of data. Other than that, it is up to you and remember both codes we are talking about and Johns code can be used to run automatically if you choose.

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

    Re: Creating a unique list from a list of duplicates

    ssu

    I haven't.

    That 1 is for xlYes for header protocol.
    As your data in original column has header, I made it 1.
    If you don't want header at the destination, need a bit change.

  26. #26
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    @Jindon, ohh yeah, my bad, you didn't change it. But tbh, i need the header at the destination and its working like a charm.
    @Dave. I'm going to try your code now and get back to you on it. The current amount of records are around 500, and data entry has just started, so one can estimate that the sheet will end up being quite large.

  27. #27
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    @Dave: If I want to run your code automatically and not as a button, what changes would I have to make to it?

  28. #28
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    Putting in Application.ScreenUpdating makes the code another 0.2 secs faster.

    You could do it as the others have done it.
    Like this,

    Please Login or Register  to view this content.
    Or you could do as a change event, so when ever you enter data it will automatically do it the moment you press enter or click a different cell. If you want it done this way, you will need to say which column you will have this data in.

    Cheers Dave
    Last edited by JapanDave; 04-23-2013 at 04:48 AM.

  29. #29
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    @Dave, thanks again for editing the code. I am using your Dup-1.xlsm to experiment but it keeps giving me an error. I first ran your new code through it and its tell me that variable 'a' is not defined. I tried to edit it to this:

    Please Login or Register  to view this content.
    But its still not liking the code :S
    Last edited by ssu; 04-23-2013 at 05:43 AM.

  30. #30
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    ssu, try to use the code tags when posting code. Its the # in the menu bar.

    If you want to define the sheet then Try this,

    Please Login or Register  to view this content.

  31. #31
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    @Dave, my bad, sorry about that! Right, so i have tried your new code and its telling me that variable 'a' is not defined.

  32. #32
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Creating a unique list from a list of duplicates

    take care of this
    Please Login or Register  to view this content.

  33. #33
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Creating a unique list from a list of duplicates

    Does this formula approach work for you?

    1/. Make a dynamic named range in sheet 'Pre - General Training'
    Name:= "Events"
    Refers to:=
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    2/. in say A2 in Sheet 'Need for further training', drag down until blanks are returned, then a bit more to allow for your longest expected list.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This should work provided there are no blanks in your original list. I'm also assuming they are all text entries.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  34. #34
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    Ok Try this,

    Please Login or Register  to view this content.
    @Marcol, nice formula!!!

  35. #35
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Thanks dave! This works much better! The only problem is that is there are any deletions to the duplicate column in the first sheet, the code doesn't update the second sheet. However, fr my needs, this would not be a problem, as there would be any deletions to the first sheet, only additions. Thanks everyone for your help :D

  36. #36
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Creating a unique list from a list of duplicates

    In that case try this,
    And if you can tell me what column the data is in on the sheet with the duplicates, I can make it so that it will update any time the data is touched.
    Please Login or Register  to view this content.

  37. #37
    Registered User
    Join Date
    04-23-2013
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Creating a unique list from a list of duplicates

    Hey Dave, just saw your message. Your code looks good. What changes would I have to make to it if both my duplicate column and the column to paste the unique data are the second columns, not the first?

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

    Re: Creating a unique list from a list of duplicates

    Re: your message.
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.

  39. #39
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,794

    Re: Creating a unique list from a list of duplicates

    You started off asking for a macro OR a formula, but most of your replies have been macros (except for Marcol's). Here's a link to a site which describes how to do this using formulae:

    http://www.get-digital-help.com/2009...om-one-column/

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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