+ Reply to Thread
Results 1 to 15 of 15

Color cells based on multiple condition

  1. #1
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Color cells based on multiple condition

    Hi,

    1)If value in range B2:B21 is 800 then color yellow, if less than 800 and greater than 0 then color red.
    2)If value in range B2:B21 is 480 then color yellow, if less than 480 and greater than 0 then color red.
    3)If value in range B2:B21 is 600 then color yellow, if less than 600 and greater than 0 then color red.

    Thanks
    Please click the * Add Reputation if this helps
    If solved remember to mark Thread as solved

    "I'm glad to help and this is not meant to sound smart, but either you have super-human vision to see all those controls cleared one by one with the code I posted, or your computer is really slow."

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Color cells based on multiple condition

    May be
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Color cells based on multiple condition

    Quote Originally Posted by Blokeman View Post
    1)If value in range B2:B21 is 800 then color yellow, if less than 800 and greater than 0 then color red.
    2)If value in range B2:B21 is 480 then color yellow, if less than 480 and greater than 0 then color red.
    3)If value in range B2:B21 is 600 then color yellow, if less than 600 and greater than 0 then color red.
    Your requirements are conflicting
    480 then color yellow...but anything < 800 and > 0 is colored red?
    likewise for < 600
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    Thanks YasserKhalil and FDibbins for the response,

    attached sample

    Based on dropdown list in cell F2 (sheet2), range B1:B21 will change value.
    Attached Files Attached Files

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Color cells based on multiple condition

    Thanks for the file, but it appears to me that your rules are still in conflict? Can you expand on what you are trying to do?

  6. #6
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    Hi FDibbins,

    Based on the selection in cell F2, range B1:B21 change, the condition will change based on the value in F2.

    Thanks

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Color cells based on multiple condition

    You are missing my question.

    1)If value in range B2:B21 is 800 then color yellow, if less than 800 and greater than 0 then color red.
    2)If value in range B2:B21 is 480 then color yellow, if less than 480 and greater than 0 then color red.
    3)If value in range B2:B21 is 600 then color yellow, if less than 600 and greater than 0 then color red.
    You want 800, 600 or 480 to be yellow, but at the same time, you want anything less than 800 to be red.

    for example, if a value is 600, should it be yellow (because it is = 600) or should it be red (because it is < 800)?
    what color would 601 be - and why?
    what color would 599 be - and why?

  8. #8
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    Is there any solution even if we change the color? (ex. 480=yellow, 600=blue, and 800=green). if you select 480 in drop down list then the value in range B2:B21 will not go above 480 same as 800 and 600.
    Here is the link how B1:B21 populate. I don't know if this help.
    http://www.excelforum.com/excel-prog...-criteria.html

  9. #9
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Color cells based on multiple condition

    For your first example aren't you really trying to say this:
    If the value selected in the drop down box F2 is 800
    Then with cells B2:B21, color them yellow if they are 800, if they are less than 800 and greater than 0 then color them red.
    So you say they won't be greater than the selection in the drop down box?
    If they are 0 or less than what color, or is that not possible with your spreadsheet?
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  10. #10
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    Quote Originally Posted by skywriter View Post
    So you say they won't be greater than the selection in the drop down box?
    Yes
    Quote Originally Posted by skywriter View Post
    If they are 0 or less than what color, or is that not possible with your spreadsheet?
    There is no 0 value, if blank cells then no color

  11. #11
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Color cells based on multiple condition

    What about this part?
    For your first example aren't you really trying to say this:
    If the value selected in the drop down box F2 is 800
    Then with cells B2:B21, color them yellow if they are 800, if they are less than 800 and greater than 0 then color them red.

  12. #12
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Color cells based on multiple condition

    To see where the code goes on the sheet, right click on the Sheet2 tab and choose view code.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    Hi skywriter, it's working but can you please amend the code to automatically run every time cell L8(sheet1) change instead of choosing same value in drop down list.

    Thanks

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Color cells based on multiple condition

    Do you mean that part
    Please Login or Register  to view this content.
    If so just change that part with
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Color cells based on multiple condition

    @YasserKhalil, I've done that but it color the cells with red.

+ 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] Returning a YES or NO based on the condition of multiple other cells
    By Coubs3 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-01-2014, 10:53 AM
  2. Replies: 3
    Last Post: 01-08-2014, 03:56 PM
  3. [SOLVED] If condition based on the color of the cell in VBA
    By rbs123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-02-2013, 02:23 AM
  4. Excel Macro to insert two rows based on condition and copy and paste multiple cells
    By mannabhalo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 12:56 PM
  5. [SOLVED] Color cells in Range based on condition.
    By gammaman in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-24-2012, 10:27 AM
  6. [SOLVED] Filling multiple cells based on condition
    By Mickey400z in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2012, 03:19 AM
  7. How to color the cell based on some condition?
    By ananthakumar.e in forum Excel General
    Replies: 3
    Last Post: 03-07-2008, 10:16 AM

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