+ Reply to Thread
Results 1 to 11 of 11

Highlighting cell based on two criteria

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

    Highlighting cell based on two criteria

    I am trying to write some code that will compare two cells on a row and if they match then it will highlight another cell on the same row.

    Column U-has Y, N entered
    Column V-has Y, N entered
    Column G-has a name entered

    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 N then the macro would highlight the cell G2 yellow.
    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.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Does it have to be a macro? Conditional Formatting is a feature that should work for you.

    Select column G and go to Format|Conditional Formatting.

    Select Formula Is from the 1st drop down and enter formula: =And($U1="N",$V1="N")

    Click Format and choose your colour from the Pattern tab.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    How would I do the conditional formating if I need it to look at cell U2 and if there is a N, and V2 has a N or is blank then the conditional format would highlight G2 yellow?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Replace with this formula:

    =And($U1="N",OR($V1="N",$V1=""))

  5. #5
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    I tried =AND($U1="N",OR($V1="N",$V1="")) and it does not appear to be working

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Did you select all of column G and then applied the formula in the conditional Formatting window...as I wrote it?

    I tested it and it does work for both conditions.

  7. #7
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    I did select Column G

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    V1 can't both be "N" and also be blank...

    My formula should be what you are looking for.

  9. #9
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    You are correct V1 will only be either be N or blank...

    I put in =AND($U1="N",OR($V1="N",$V1=""))

    I have 2 rows that has Column U as N and Column V as blank and the forumla does not highlight the cell in Column G

    I doubled checked everything with no luck

  10. #10
    Forum Contributor
    Join Date
    07-24-2008
    Location
    San Antonio, Texas
    Posts
    118
    Well I found the problem it looks like there were spaces in the cell

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I should make that my standard first question: "Are there extra spaces in the cell(s)?"

    You don't know how many times that has been the problem driving us mad when we know a formula should be working.

+ 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