+ Reply to Thread
Results 1 to 16 of 16

Color a cell If 2 other cells meet condition, undo cell color if third cell meet condition

  1. #1
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Color a cell If 2 other cells meet condition, undo cell color if third cell meet condition

    I have a legend with 5 specific names in a small range of cells which individually get highlighted based on conditions. However, I have rows from column A to G, that go all the way down to row 300. The columns I'm only concerned about for conditionally formatting A7:A11 are columns C16:C300, E16:E300 and G16:E300.

    If column C contains value "John", and column E contains value "PAYMENT PENDING", then color cell $A$7 YELLOW
    If column C contains value "Alex", and column E contains value "PAYMENT PENDING", then color cell $A$8 YELLOW
    If column C contains value "Smith", and column E contains value "PAYMENT PENDING", then color cell $A$9 YELLOW
    If column C contains value "Tommy", and column E contains value "PAYMENT PENDING", then color cell $A$10 YELLOW
    If column C contains value "James", and column E contains value "PAYMENT PENDING", then color cell $A$11 YELLOW

    I also need a different color ORANGE when column E contains value "PAYMENT PROCESSING" for the same conditions above.

    To clarify:

    If column C contains value "John", and column E contains value "PAYMENT P PROCESSING", then color cell $A$7 ORANGE
    If column C contains value "Alex", and column E contains value "PAYMENT P PROCESSING", then color cell $A$8 ORANGE
    If column C contains value "Smith", and column E contains value "PAYMENT P PROCESSING", then color cell $A$9 ORANGE
    If column C contains value "Tommy", and column E contains value "PAYMENT P PROCESSING", then color cell $A$10 ORANGE
    If column C contains value "James", and column E contains value "PAYMENT P PROCESSING", then color cell $A$11 ORANGE

    and then condition to undo color fill:

    If column G contains any value, and column C contains value "John" while column E contains value "PAYMENT PENDING" or "PAYMENT PROCESSING", then undo color for cell $A$7
    If column G contains any value, and column C contains value "Alex" while column E contains value "PAYMENT PENDING" or "PAYMENT PROCESSING", then undo color for cell $A$8
    If column G contains any value, and column C contains value "Smith" while column E contains value "PAYMENT PENDING" or "PAYMENT PROCESSING", then undo color for cell $A$9
    If column G contains any value, and column C contains value "Tommy" while column E contains value "PAYMENT PENDING" or "PAYMENT PROCESSING", then undo color for cell $A$10
    If column G contains any value, and column C contains value "James" while column E contains value "PAYMENT PENDING" or "PAYMENT PROCESSING", then undo color for cell $A$11

    NXuHU0k.jpg

    Basically, I just want the cells in $A$7:$A$11 to be colored conditionally and then undo coloring when a later condition is met. Keep in mind, I begin at row 16 and gradually fill out the rows down to row 300 throughout the day, so I want to be able to see the cells in the legend get conditionally highlighted only when I enter the values mentioned above.

    I know this is a tall order, and I have asked in another forum but with no luck thus far... I'm hoping VBA might be the answer to my problem. Thank you so much for any help!

  2. #2
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    @ aftbrah

    You can try with this code,
    it will act every time you change a value in your data table
    it recognizes automatically the size of the table

    You'd copy and paste the code into worksheet module corresponding to your page:
    .- press Alt F11 to open de Editor
    .- Doble click on "Sheet1(Instructions)
    .- Paste de code

    then just play around to see if it's OK
    Barriers are there for those who don't want to dream

  3. #3
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Sorry, forgot to attach the code:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    hmmm I entered that code but it did not work. No error messages or anything, just simply nothing happens when I meet the conditions.

  5. #5
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    weird,
    It's working for me !
    did you placed the code in the proper sheet ?
    Captura.JPG

  6. #6
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Here's a screenshot of mine. I did the exact same

    paymentpending.jpg

    Doesn't work for me :/

  7. #7
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    In your first screenshot you placed:
    List of Names in A7:A11

    and your table was:
    list of names C16:C..."lastData" that is column 3
    list of PAYMENT E16:E..."lastData" that is column 5
    list of complete G16:G..."lastData" that is column 7

    I used this positions in the code I posted

    In my screenshot I used columns C,D,E but I posted for yours. so don't care about "my columns position"... use yours C,E,G which are 3,5,7 according to the code you have.
    Sorry if I mislead with my image.

  8. #8
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Hmmm.. i tried it but it partially works. It misses it half the time and then I have to re-input the values in the cells hoping it works again. I'm not sure but it might be the specific conditions in the script that don't account for certain events. This is a running document, so the values are entered on-the-go. I don't know if that helps.

    Thank you for all the help so far though, EXTREMELY appreciate your generous time

  9. #9
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    I appreciate your words.I'm happy helping people...feel free to ask.

    The worksheet change event acts every time you change by direct action the value of any cell in columns C E and G within the range of the table.
    It does not act when the changes are a result of formula calculations.....
    If you tell me how your sheet works, we can find a way to solve.... in Excel almoxt everithing is possible.
    I don't follow what "certain events" and "values are entered on the go" means.

  10. #10
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Okay I think I figured out the nature of the bug. When I begin backwards, then it works. For example, if I enter John in C18, PAYMENT PENDING in E18, then go to next row up (C17, E17) and enter information, then it works. But when I begin from row 16 and go down the table it doesn't work. Its weird but that is what is happening now.

    Basically, I think the script is reading it backwards (C300:C16, E300:E16, etc) instead of the other way around (C16:C300, E16:E300, etc). That is just my guess, but I am not sure how that makes sense either lol
    Last edited by aftbrah; 10-27-2016 at 08:36 PM.

  11. #11
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    The code itself has nothing to do with the order you input data.
    It just is triggered whenever you change the value in a cell within the range.
    Do you always input data in certain order? For instance first C then E...if it is so, we can suspend the control over C, and keep controling E and G.
    Then you can replace this line
    If Target.Column = 3 Or Target.Column = 5 Or Target.Column = 7 Then
    With
    If Target.Column = 5 Or Target.Column = 7 Then

    In my test it works OK...no diference with any order..
    Now, I found a mistake while writing this.
    Do not change the previoun row.(just forget it)
    The code is not checking the last row...to solve the problem changethis line:
    If Target.Row > 15 And Target.Row < lastData Then
    With this:
    If Target.Row > 15 And Target.Row < lastData +1 Then

    I hope it will make the difference

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Perhaps
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Quote Originally Posted by vichopalacios View Post
    The code itself has nothing to do with the order you input data.
    It just is triggered whenever you change the value in a cell within the range.
    Do you always input data in certain order? For instance first C then E...if it is so, we can suspend the control over C, and keep controling E and G.
    Then you can replace this line
    If Target.Column = 3 Or Target.Column = 5 Or Target.Column = 7 Then
    With
    If Target.Column = 5 Or Target.Column = 7 Then

    In my test it works OK...no diference with any order..
    Now, I found a mistake while writing this.
    Do not change the previoun row.(just forget it)
    The code is not checking the last row...to solve the problem changethis line:
    If Target.Row > 15 And Target.Row < lastData Then
    With this:
    If Target.Row > 15 And Target.Row < lastData +1 Then

    I hope it will make the difference
    It works now thank you so much! I especially like that the cell in column C range is also highlighted. It makes it a lot easier to scroll through the table to figure out where "John" has a payment pending, etc. Quick question, is there a way to make it an array like the poster jindon has it? So that it isn't strictly the name in the cell, but as long as the cell contains the name.

    Quote Originally Posted by jindon View Post
    Perhaps
    Please Login or Register  to view this content.
    This works as well! Thank you so much. You guys at ExcelForum.com are awesome!
    Last edited by aftbrah; 10-28-2016 at 12:35 AM.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    Quote Originally Posted by aftbrah View Post
    I especially like that the cell in column C range is also highlighted. It makes it a lot easier to scroll through the table to figure out where "John" has a payment pending,
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    10-22-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    19

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    PERFECT! Thank you guys so much!

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Color a cell If 2 other cells meet condition, undo cell color if third cell meet condi

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find first cell meet a condition within a range
    By kingi in forum Excel General
    Replies: 6
    Last Post: 01-07-2015, 08:20 PM
  2. highlight cell if meet condition
    By airbatucampur92 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-10-2014, 01:04 AM
  3. [SOLVED] Toggle fill Color in cell based on condition of cell--blank or text added.
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2014, 08:39 PM
  4. [SOLVED] Conditional format one cell if any cells in column meet condition
    By jben86 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-24-2013, 01:04 AM
  5. Replies: 6
    Last Post: 07-03-2009, 05:25 AM
  6. Show if any cell has meet condition
    By Danielle123 in forum Excel General
    Replies: 4
    Last Post: 03-25-2008, 03:19 PM
  7. sum of a cell if 2 cells meet a condition
    By Markitos in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-04-2005, 02:06 PM

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