+ Reply to Thread
Results 1 to 10 of 10

Compare three cells and delete row

  1. #1
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118

    Compare three cells and delete row

    I am trying to write some code that will compare three cells on a row and if they match then it will delete the row.

    Column U-has Y, N entered
    Column V-has Y, N entered
    Column O-has 1, 2, entered (some cells may have the fill color set to red)

    I need the macro to look at Column U and Column V and for example if the cell U2 has a N, and V2 has a Y then the macro would look at O2 and it there is a 1 with the fill color set to red the macro will delete that row.
    The spreadsheet will vary on how many rows it contains. It can contain up to 5,000 rows and the macro would need to go through all the rows.
    Any help would be greatly appreciated. Thanks

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    do they have to be deleted or can they be hiden?

  3. #3
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    Deleted if possible

  4. #4
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    nearly anything is possible

    a couple of ways to do this,

    i am assuming the list starts on row 1

    Please Login or Register  to view this content.
    this is one way of doing this and i think it may be the easiest way
    Last edited by Stuie; 07-25-2008 at 09:09 AM.

  5. #5
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    How about if Column U and Column V and for example if the cell U2 has a N, and V2 has a Y and it would delete the row unless O2 has a 1 in it with the fill color set to red then the macro would not delete that row?

  6. #6
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    sorry, i dont quite fully understand what you mean

  7. #7
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    Just to clarify...

    Column U-has Y, N entered
    Column V-has Y, N entered
    Column O-has 1, 2, entered (some cells may have the fill color set to red)

    For example if the cell U2 has a N in the cell, and V2 has a Y in the cell then the macro would delete the row unless O2 has a 1 in the cell with the fill color set to red then it would not delete the row. If O2 has a 1 in the cell with no fill color then the macro would delete the row.
    The spreadsheet will vary on how many rows it contains. It can contain up to 5,000 rows and the macro would need to go through all the rows.

  8. #8
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    oh ok sorry, im being a bit thick today.

    try this,

    Please Login or Register  to view this content.
    this says if col u value = N and col v value = Y and O value = 1 and o fill color isnt red then delete

  9. #9
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    Thank you...it works
    Last edited by randolphoralph; 07-25-2008 at 12:10 PM.

  10. #10
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    No problem, glad to help

+ 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