+ Reply to Thread
Results 1 to 6 of 6

Remove duplicates that match in two columns

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Remove duplicates that match in two columns

    Hi,

    Looking for code to run a macro button that will remove duplicate and original rows that match in two columns.

    The example is set up as my working document so needs to run from row 6 as shown and match data in columns B & F

    So in the example, rows 10 & 11, 17 & 18, 21 & 22, 24 & 25 would be removed but not rows 27 & 28.

    Thanks
    Attached Files Attached Files

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

    Re: Remove duplicates that match in two columns

    Let's try this for starters.
    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.

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Remove duplicates that match in two columns

    That seems to work perfectly, thanks.

    I had looked up a lot of code which seemed much more complex than yours which is why I was getting confused.
    Just for future clarification, what does Range "M6" "M" do after Next as there is nothing in this column?

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

    Re: Remove duplicates that match in two columns

    The code between For and Next checks the conditions and if met puts a 1 in Column M in both rows.
    The codeline after Next cheks for these 1's and removes all lines that meet criteria.
    You can check this if you put a Stop marker after Next (F9) and check your worksheet before proceeding the code.

  5. #5
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Remove duplicates that match in two columns

    That makes sense, thanks for the explanation and the code

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

    Re: Remove duplicates that match in two columns

    You're welcome and glad to help.

+ 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. [SOLVED] Remove duplicates from all columns.
    By DanzaNZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2016, 08:31 PM
  2. Remove Duplicates That Don't Match Certain Value in Another Column
    By stusic in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2015, 04:37 PM
  3. [SOLVED] index match remove duplicates
    By sick stigma in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-26-2015, 12:22 PM
  4. Index Match from two columns and Remove duplicates,
    By gurkovic in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-16-2014, 05:18 AM
  5. Remove Duplicates in columns
    By naveenmarapaka in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-31-2014, 11:10 AM
  6. Compare 2 columns and remove duplicates in both columns when found
    By 1dtms in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-11-2013, 02:19 AM
  7. remove duplicates based on partial text match
    By smelkin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-16-2011, 09:45 AM

Tags for this Thread

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