+ Reply to Thread
Results 1 to 3 of 3

Delete rows if any cell in Sheet 1 rows matches any cell in Sheet2 column

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    2

    Delete rows if any cell in Sheet 1 rows matches any cell in Sheet2 column

    Hi!

    I'm needing an Excel 2003 VBA macro that would perform the following:

    If any cell in Sheet1!A2:D2 matches any cell in Sheet2!B5:B7, then row Sheet1!A2:D2 is deleted;
    If any cell in Sheet1!A3:D3 matches any cell in Sheet2!B5:B7, then row Sheet1!A3:D3 is deleted;
    If any cell in Sheet1!A4:D4 matches any cell in Sheet2!B5:B7, then row Sheet1!A4:D4 is deleted;

    ...and so on, through...

    If any cell in Sheet1!A9:D9 matches any cell in Sheet2!B5:B7, then row Sheet1!A9:D9 is deleted;

    The remaining/resulting rows would be:

    Col1 Col2 Col3 Col4
    pizza red tim pork
    yellow green shrimp cheese
    dan purple tara white
    fish bread brown heather
    pink mary ryan teresa

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete rows if any cell in Sheet 1 rows matches any cell in Sheet2 column

    F1 = "Key"
    F2 = =IF(OR(ISNUMBER(SEARCH(Sheet2!$B$5:$B$7, A2&B2&C2&D2))),"yes", "no")

    Confirm the array formula above by pressing CTRL-SHIFT-ENTER to activate the array, you will see curly braces { } appear around your formula.

    Copy F2 down.

    Turn on the Data > Filter > AutoFilter on column F

    Filter for "yes"

    Delete all the visible rows.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Delete rows if any cell in Sheet 1 rows matches any cell in Sheet2 column

    Thank you, Jerry!

+ 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