+ Reply to Thread
Results 1 to 4 of 4

Deleting rows, Multiple criteria

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Deleting rows, Multiple criteria

    Column A contains orders numbers, and some are identical. Example: row 1 and 4 are the same:
    -- A
    1234
    2345
    3456
    1234
    4567

    Column B contains 1 or 0. So we see:
    -- A -------> B
    1234 ----> 1
    2345 ----> 0
    3456 ----> 0
    1234 ----> 0
    4567 ----> 0

    What I need is code that will delete rows where Column B contains a "1" value. But I also need this code to examine the order number for that row, found in Column A. Then go and delete all rows where that particular order number might be found in Column A, even if its corresponding Column B data is a "0" value.
    Last edited by Wedge120; 06-29-2011 at 10:50 PM. Reason: descriptive subject

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: need help deleting rows, single criteria, possibly need a function

    Hi,

    One way would be to use a couple of helper columns. In column C use
    =IF(COUNTIF($A1:$A100,A1)>1,1,0)
    copy this down
    In the adjacent column D enter
    =IF(OR(B1=1,C1=1),1,0))
    copy this down then filter the whole of the data using column D for the value 1 and once filtered select and then delete all the filtered rows.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Deleting rows, single criteria

    This almost works..

    The problem arises when I have duplicate order numbers and column B for both have a "0" value. In this case, I do not need to delete them.
    Last edited by Wedge120; 06-28-2011 at 11:42 PM. Reason: grammer

  4. #4
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Deleting rows, Multiple criteria

    So, could I achieve my goal better by creating a lookup table?

    -- A -------> B
    1234 ----> 1
    2345 ----> 0
    3456 ----> 0
    1234 ----> 0
    4567 ----> 0
    2345 ----> 0

    Look at rows 2 and 6, column A. They are identical. Their corresponding value in column B is "0", which means I need not delete these rows.
    Last edited by Wedge120; 06-29-2011 at 11:05 PM.

+ 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