Find Duplicate - Delete Rows that do not match

  • Hello,


    I have attached a document to make this request a little easier as well.


    I am trying to match data in sheet1 to sheet3. The matching data in sheet1 is in column I and it would look to match column F in Sheet3. Any match not found would be deleted (the row and data) from sheet1. There is a macro in there already, but it was created to find duplicates and delete the duplicates. Now I am trying to do the opposite.


    Any help would be greatly appreciated.


    Thank you.

    Files

    • Trial.xlsm

      (22.17 kB, downloaded 82 times, last: )
  • Re: Find Duplicate - Delete Rows that do not match


    Hi



    Try the following. It uses a vlookup and the filter function to remove the rows that don't match.



    Take care



    Smallman


  • Re: Find Duplicate - Delete Rows that do not match


    Hello,


    Thank you for the help. I did notice that the macro deletes everything on sheet1 upon running the macro though. The only thing I wanted deleted was the rows that do not match based on the columns listed.

  • Re: Find Duplicate - Delete Rows that do not match


    Hi


    The code provided deletes only the cells which do not mach to sheet2. You are using xl 2007 or later so all you had to do was to simply go Data and hit the filter button. The rest of the data is in the filter. Alternatively you could add the following line in vb which takes the manual process out.


    Code
    1. Columns("J").AutoFilter


    I have attached a file this time with the above line.


    Take care


    Smallman

  • Re: Find Duplicate - Delete Rows that do not match


    Thank you for your assistance! After posting, I noticed that column J had the filtered option and created a workaround to remove it but your solution is more streamlined. Thank you.