+ Reply to Thread
Results 1 to 18 of 18

Macro to delete all Duplicate items in Col B

  1. #1
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Macro to delete all Duplicate items in Col B

    I have code to delete all items that are duplicated, but none are being deleted


    I have attached my workbook showing the duplicated items and the rows containing the items highlighted are to be deleted


    The macro is



    Please Login or Register  to view this content.

    It would be appreciated if someone could kindly amend my code to accommodate my request
    Last edited by flupsie; 06-14-2018 at 10:44 AM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to delete all Duplicate items in Col B

    There's no file attached.

    BSB

  3. #3
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    My apologies-forgot to attach the workbook
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to delete all Duplicate items in Col B

    You're putting the formula in starting at C6, it needs to start in C2, like
    Please Login or Register  to view this content.

  5. #5
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Thanks for your input


    I need the code amended so that all duplicates are removed for eg if KL-803133022 appears more than once all the references for KL-803133022 are to to be deleted


    I have attached a workbook showing which items should be left once the duplicate items are deleted


    Kindly amend my code
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to delete all Duplicate items in Col B

    Have you tried the change I suggested?
    As that works on the original file

  7. #7
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    I have amended the macro as suggested



    I have attached a workbook after running the macro to show you what items remain. The original data is on sheet "original Data"


    Please check & amend
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to delete all Duplicate items in Col B

    It's not working because you have changed the formula

  9. #9
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Hi Fluff13

    I amended the formula from


    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

    When running the all the items containing the same reference is to be deleted




    The following items per my sample data is to be deleted


    KL-803133022
    KL-803133022
    KL-803133060
    KL-803133060


    Kindly amend code accordingly

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to delete all Duplicate items in Col B

    That is not a formula, this is
    Please Login or Register  to view this content.
    & you have changed it.

  11. #11
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Have changed it to

    Please Login or Register  to view this content.
    It now results in
    KL-803133022
    KL-803133060


    The result should be

    KL-803133040
    KL-803133041
    KL-803133061


    Kindly check & amend the code

  12. #12
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Macro to delete all Duplicate items in Col B

    No vba needed. Use a pivottable or use Remove Duplicates or use the advanced filter.

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to delete all Duplicate items in Col B

    Quote Originally Posted by flupsie View Post
    Have changed it to
    I know you've changed it. What I'm saying is change it back to what it was originally.

  14. #14
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Thanks , but I need to remove all items that are the same for eg if I have 985 in Col B and it appears more than one, for eg 3 times, then all the items containing 985 must be deleted in Col B

  15. #15
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Hi Fluff13


    I changed it back to what is was originally , but still not giving me the desired result


    In my example the rows containing these 4 items are to be deleted

    KL-803133022
    KL-803133022
    KL-803133060
    KL-803133060

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

    Re: Macro to delete all Duplicate items in Col B

    How about this.
    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.

  17. #17
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to delete all Duplicate items in Col B

    Thanks for the help, Code works perfectly

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

    Re: Macro to delete all Duplicate items in Col B

    Glad to help. Thanks for rep+.

+ 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. Replies: 11
    Last Post: 12-08-2015, 06:33 PM
  2. [SOLVED] Delete duplicate items in list in userform
    By CtrlAltDelete in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-17-2014, 11:30 AM
  3. Replies: 2
    Last Post: 06-05-2014, 01:28 PM
  4. [SOLVED] Macro to Delete Rows and Renumber Items after
    By jaredmccullough in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-15-2014, 03:49 PM
  5. [SOLVED] Need Filter+Export to PDF+Delete Filtered Items Macro
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-02-2012, 03:38 PM
  6. macro to delete selected validation list items?
    By rahulknras in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2011, 08:26 AM
  7. i want to delete duplicate items in a list using code.
    By ndm berry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2005, 10:05 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