+ Reply to Thread
Results 1 to 7 of 7

Search Cell Value Delete if Not in Named Range

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Search Cell Value Delete if Not in Named Range

    I am pretty new to VBA I am basically trying to search all the cell values in column K of multiple sheets. If the value in column K is not found in my named range I want it to delete the entire row. Any help is greatly appreciated!!!!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Search Cell Value Delete if Not in Named Range

    1. What is your named Range called and what sheet is it on?
    2. Exactly which sheets do you want to compare column K to the named Range?
    3. Do you want to delete the row of column K when it does not match anything in the named range OR do you want to delete the row of the named range if it does not match anything in column K?
    4. Are there any other sheets that will have nothing to do with this? (dont want to set a macro to work across all sheets if it needs to be specific)

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Search Cell Value Delete if Not in Named Range

    Quote Originally Posted by stnkynts View Post
    1. What is your named Range called and what sheet is it on?
    2. Exactly which sheets do you want to compare column K to the named Range?
    3. Do you want to delete the row of column K when it does not match anything in the named range OR do you want to delete the row of the named range if it does not match anything in column K?
    4. Are there any other sheets that will have nothing to do with this? (dont want to set a macro to work across all sheets if it needs to be specific)
    1. The named range is called "TABMODELS"
    2. Sheet3 i want to compare column J to the named range, Sheet4 & Sheet5 I want to compare column K to the named range.
    3. I want to delete the row of column K/J when it does not match anything in the named range.
    4. There are other sheets in the workbook, so it does have to be sheet specific.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Search Cell Value Delete if Not in Named Range

    I assumed that the named range was on a sheet called Sheet1. I also assumed that Sheet4 and Sheet5 are the 4th and 5th sheet numerically. I set the loop to go to the first row so if you have a header you may want to change that or else the header is going to go away. I would suggest trying this on a copy of your workbook since there will be a lot of deleting going on.

    Please Login or Register  to view this content.
    Last edited by stnkynts; 12-04-2012 at 01:46 PM.

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Search Cell Value Delete if Not in Named Range

    Quote Originally Posted by stnkynts View Post
    Please Login or Register  to view this content.
    Is there anyway to make this stop deleting at row 3 on sheet 3, 4, & 5? I have headings in row 1 & 2 on sheet3, sheet4, and sheet5 and don't want to delete those rows. Otherwise it works great!

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Search Cell Value Delete if Not in Named Range

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-04-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Search Cell Value Delete if Not in Named Range

    Ah, you are genius! Thanks so much for your help! You just saved me tons of manual effort every month!

+ 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