+ Reply to Thread
Results 1 to 7 of 7

How to compare columns in 2 sheets then delete if no match

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    Phoenix, Arizona
    MS-Off Ver
    2007
    Posts
    9

    How to compare columns in 2 sheets then delete if no match

    Hello,
    1st Sheet "KEY"
    2nd sheet "Sheet3"

    1) Go through Col E in "Sheet3" (rows can vary in length) don't want to hardcode. Plus headers exist in row 1
    2) compare to "KEY" Col A. (no header in this sheet)
    3) If no match then delete row in "Sheet3"

    How do I go about writing the code?
    Just stumped how to go about this.

    Thanks,
    asu

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to compare columns in 2 sheets then delete if no match

    I assume column F of Sheet 3 is empty

    In which case this macro would help.

    Please Login or Register  to view this content.

    I added some error checking:-

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-25-2017 at 02:57 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    04-16-2015
    Location
    Phoenix, Arizona
    MS-Off Ver
    2007
    Posts
    9

    Re: How to compare columns in 2 sheets then delete if no match

    On "Sheet3" Col A-F are occupied with data.

    Since code is running through Col E I noticed it cleared contents of Col F.

    How do I keep COl F data intact?

    Looks like matching & deleting rows is working but need COL F to stay intact.

    Thanks,
    asu

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How to compare columns in 2 sheets then delete if no match

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 08-25-2017 at 04:13 PM.

  5. #5
    Registered User
    Join Date
    04-16-2015
    Location
    Phoenix, Arizona
    MS-Off Ver
    2007
    Posts
    9

    Re: How to compare columns in 2 sheets then delete if no match

    Thank you so much!!

    I changed the [-5] to [-6]

    You saved me hours if not days trying to figure this out.

    Thanks,
    asu

  6. #6
    Registered User
    Join Date
    04-16-2015
    Location
    Phoenix, Arizona
    MS-Off Ver
    2007
    Posts
    9

    Re: How to compare columns in 2 sheets then delete if no match

    I just noticed that it was not matching all data.

    Is there a way I can attach sample file .xslm without exceeding size? My file exceeds the attachment size 240KB

    Thanks,
    asu

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,697

    Re: How to compare columns in 2 sheets then delete if no match

    Assumes that Column J in Sheet3 is empty.

    Please Login or Register  to view this content.

    If you want to attach a file that is too big, make it smaller!

+ 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. Compare 2 columns, delete cells with no match
    By cmd in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-22-2019, 04:52 AM
  2. Default Compare 2 sheets and delete entire row if don't match
    By lapot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2016, 02:27 PM
  3. [SOLVED] Compare two columns in two sheets and delete if existed
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2016, 06:30 AM
  4. Replies: 7
    Last Post: 04-18-2016, 02:26 AM
  5. Compare columns on 2 sheets and delete row based on format
    By tifferpat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2015, 04:37 PM
  6. Compare two columns from diff excel sheets and delete all non matching rows
    By Girija in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2013, 11:08 PM
  7. Compare two sheets and delete row if match found
    By Steinwall in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2011, 03:25 PM

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