+ Reply to Thread
Results 1 to 21 of 21

remove duplicates in column

  1. #1
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    remove duplicates in column

    Hi All,

    is there any way that i can have a macro that will delete the duplicates in column AC?

    Thanks!

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: remove duplicates in column

    Maybe:
    Please Login or Register  to view this content.
    Last edited by Mumps1; 08-05-2015 at 11:19 AM.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: remove duplicates in column

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Hi John,

    Thanks for this, but i need to retain my headers. I just need the code to run from AC4 going down. Any idea?

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: remove duplicates in column

    Maybe:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: remove duplicates in column

    Here's another version.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Hi John,

    can you see the attached file so you can check? It seems like its not removing dups and spaces as well.

    or i did it wrong?
    Attached Files Attached Files

  8. #8
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    For the last code you gave it was actually working but i need the column headers

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: remove duplicates in column

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    hi AB33,

    Uusing your code but i was able to remove duplicate but the spaces remains.

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: remove duplicates in column

    Actually - the code AB33 gave should be removing those spaces w/o a sort.

    Here's what I got from the macro recorder(modified a bit) - this moves the values into one continuous list at the top w/o sorting the sheet.


    Please Login or Register  to view this content.
    That should be all that is needed
    Last edited by GeneralDisarray; 08-07-2015 at 09:22 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  12. #12
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Hi GeneralDisarray,

    yes i need this to happen without the sorting

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: remove duplicates in column

    I do not know what kind of spaces, if they are chr(10).
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Hi AB33,

    there will be an instance that in column AJ, that the duplicates will have spaces - meaning blank cells before them like this in the attached file.

    I have to remove duplicates as well as to remove the spcaes betweem them also.

    Sorry not not clearly explaning
    Attached Files Attached Files

  15. #15
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: remove duplicates in column

    Hi -

    How about like this one?
    Please Login or Register  to view this content.
    event

  16. #16
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Hi GeneralDisarray

    I got your code its actually working but i have data in AJ4, the code starts to run below it meaning from Aj5 downward and now i got double A in Column Aj and its has spaces. Attached is the file

  17. #17
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    hi event21 ,

    perfect! Thank you so much!

  18. #18
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: remove duplicates in column

    Ok, I was being dense... the sort is OK you can localize it to just that column:

    ALSO - you were saying "spaces" buy you meant "blank cells" - In your example the blanks really were blank. If you have cells with multiple spaces within them that appear blank, we'll need to add another step (but it's 100% doable).


    This does the following: Replaces blank cells with an easy to identify "ZZZZZZZZZZZZ" value. Removes duplicates, then sorts - that puts the "ZZZZZZZZZZZZ" on bottom. Finally, it does a last find-n-replace for that "ZZZZZZZZZZZZ" flag.



    Please Login or Register  to view this content.
    Attached Files Attached Files

  19. #19
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: remove duplicates in column

    Two blank rows are treated by excel as equal, hence duplicates, but if you want to remove them.


    [Code]Sub RemoveDups()
    With Sheets("Sheet1").Range("AJ4:AJ" & Range("AJ" & Rows.Count).End(xlUp).Row)
    .Value = Application.Trim(.Value)
    .RemoveDuplicates Columns:=Array(1), Header:=xlYes
    .SpecialCells(4).EntireRow.Delete
    End With
    [Code]End Sub

  20. #20
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: remove duplicates in column

    Quote Originally Posted by geliedee View Post
    For the last code you gave it was actually working but i need the column headers
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor geliedee's Avatar
    Join Date
    10-14-2013
    Location
    Manila, philippines
    MS-Off Ver
    Excel 2007
    Posts
    399

    Re: remove duplicates in column

    Thanks everyone who helped me!

+ 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. Remove Duplicates in column and remove blanks
    By geliedee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-13-2015, 07:25 AM
  2. Replies: 5
    Last Post: 05-08-2014, 07:24 AM
  3. remove duplicates in column
    By MsLilly in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-29-2009, 01:08 PM
  4. How to remove duplicates from a column
    By LLocal in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-13-2009, 05:44 PM
  5. Remove duplicates in column D
    By maxebi in forum Excel General
    Replies: 3
    Last Post: 03-02-2009, 02:36 AM
  6. Possible To Remove Duplicates In A Column
    By fredmeister in forum Excel General
    Replies: 3
    Last Post: 04-02-2008, 05:19 PM
  7. How to remove duplicates from a column
    By wali in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-14-2008, 11:33 AM

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