+ Reply to Thread
Results 1 to 4 of 4

Compare data in selected columns and delete all matching rows

  1. #1
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Compare data in selected columns and delete all matching rows

    Hello all. I have looked through the forum but have not yet come across a solution to my specific problem. I need some code that will look at cells in several columns (A, B, C, and G in the attached file), and delete the row on the OrigSheet if all 4 cells match the same columns on the ReferenceSheet. The OrigSheetAfterCode shows the desired results. I have over 186,000 rows to sort through and I would like to be able to modify the columns to compare against for future comparisons.

    Thanks,
    Andrew
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-31-2010
    Location
    essex
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Compare data in selected columns and delete all matching rows

    Hi

    Its a bit slow but it does the job

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare data in selected columns and delete all matching rows

    Hello Lima. Thanks for the code!! That is a very interesting method and although it does add the formulas to some blank rows after the last row of data, that did not apper to affect the test spreadsheet. I will try it on a copy of the main and hopefully it will produce the desired results. I like that it will be easy to change the columns I want to match since I will be using this for different comparisons. I wonder if the column selectons could be added to the macro via a userform. The user would enter the columns to compare against and the userform variables would be used by the rest of the macro.

    Andrew

  4. #4
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare data in selected columns and delete all matching rows

    After trying to tailor it to my specific sheets, I found that the way this code is written requires that the columns being matched must be in the same locations on both spreadsheets. So if I want to look for a match in column B, the reference data must also be in column B on the reference sheet. In actuality, the data format is different on both sheets since it comes from 2 different sources. I tried to specify the columns but to no use. I can move the columns around and add extra columns when needed, but is there a way to compare columns from one sheet to different columns on another sheet?

    Thanks,
    Andrew

+ 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