+ Reply to Thread
Results 1 to 7 of 7

Delete row if "cell.Value" equals a cell in a range

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    Greater Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    12

    Delete row if "cell.Value" equals a cell in a range

    Hi all, long time reader, first time poster.

    I have the code below (not mine but it runs/works fine) that basically deletes a row in a sheet if a cell in that row equals a specific value (in this case, if it equals Total World, Europe, North, or South).

    Im wondering if there is a way to modify the code below so if cell.Value equals a cell in a range in a worksheet, then it deletes that row. This would be instead of me specifying in the code "cell.Value = abc OR cell.Value = def" in order to save time and not specify in the code the hundreds of values that I want to add.

    Essentially, I want to post the values in the quotes below "Total World, Europe, North, South" in a range in a worksheet, rather than in the code. Highlighted in red is what I want to modify.
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Delete row if "cell.Value" equals a cell in a range

    Hi,

    try this file: 2 DelFromList.xlsm

    contains:
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Delete row if "cell.Value" equals a cell in a range

    Here the list of items is in I1 thru I10:

    Please Login or Register  to view this content.
    Gary's Student

  4. #4
    Registered User
    Join Date
    07-05-2013
    Location
    Greater Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Delete row if "cell.Value" equals a cell in a range

    Thank you both for the quick responses, this seems to have worked. Ill continue testing. One more question, Jakobshavn, if the arraylist is 100000 but there are empty cell values, for example from 7000-100000, will it still check to see if the cell I am checking is equal to the values in those cells (which should be blank)?

    EDIT: Jakobshavn, can I make it so the cells it checks against are in a different sheet, in case those rows get deleted? (The column of cells I want it to check against are in a sheet called Keys and column N.)
    Last edited by tonye104292; 07-05-2013 at 04:27 PM.

  5. #5
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Delete row if "cell.Value" equals a cell in a range

    Having empty cells in the checklist will not affect the outcome. Make the proper changes to the limits on ary as well as the single line:

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    917

    Re: Delete row if "cell.Value" equals a cell in a range


  7. #7
    Registered User
    Join Date
    07-05-2013
    Location
    Greater Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Delete row if "cell.Value" equals a cell in a range

    Quote Originally Posted by Jakobshavn View Post
    Having empty cells in the checklist will not affect the outcome. Make the proper changes to the limits on ary as well as the single line:

    Please Login or Register  to view this content.
    Thank you!

+ 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