+ Reply to Thread
Results 1 to 10 of 10

Conditional formatting with 6 conditions?

  1. #1
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Conditional formatting with 6 conditions?

    I'm using Excel 2000 which has a limit of three conditions, I have 6. If you could just get me started, I still don't understand VBA enough to do this.

    In cell A1, the color is set to red. I want A1 to turn green when all 6 conditions are met:

    1. Cell B1 has a valid value from its pull down list, no other value, and not empty.
    2. Cell B2 has an integer, no decimal places allowed, and not empty.
    3. Cell B3 has a valid value from its pull down list, no other value, and not empty
    4. Cell B4 is not empty.
    5. Cell B5 has a three decimal place number greater than zero.
    6. Cell B6 has a single letter from A-Z only.

    Please see the attached workbook.

    Thank you for your continued help.
    Attached Files Attached Files
    Last edited by proepert; 01-24-2010 at 12:26 AM. Reason: Solved.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Conditional formatting with 6 conditions?

    There are ample (hundreds of) examples on the forum of formatting via VBA. Have you searched?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Conditional formatting with 6 conditions?

    Hi, this can be done with just one conditional format, it's just a number of conditions combined in an AND() statement.

    Here are the conditions one by one:

    =MATCH(B1,names,0)>0
    =B2=INT(B2)
    =MATCH(B3,cities,0)>0
    =AND(B4<>"",B4<>0)
    =LEN(B5)-FIND(".",B5)=3
    =AND(CODE(UPPER(B6))>=65,CODE(UPPER(B6))<=90,LEN(B6)=1)

    And here they are combined into one formula

    Please Login or Register  to view this content.
    I'm just not sure about B5. It is formatted with three decimals. So would a number entered as 4.44 that is displayed as 4.440 qualify as true or not??

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Conditional formatting with 6 conditions?

    Believe it or not, that is still only 1 conditional formatting formula. Use these settings on cell A1:

    1) open Format > Conditional Formatting window
    2) Condition1: Formula Is:
    =AND(ISNUMBER(MATCH(B1, names, 0)), AND(B2<>"", MOD(B2,1)=0), ISNUMBER(MATCH(B3, cities, 0)), B4<>"", IF(ISNUMBER(FIND(".", B5)), LEN(MID(B5, FIND(".", B5)+1, 99))=3, FALSE), AND(LEN(B6)=1, ISTEXT(B6)))
    ...Format...Pattern tab....green color
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Conditional formatting with 6 conditions?

    JB, this

    ...AND(LEN(B6)=1, ISTEXT(B6)))

    will also allow entry of characters like "!@#$%^&*()_+" and not restrict to A-Z

  6. #6
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Re: Conditional formatting with 6 conditions?

    Quote Originally Posted by shg View Post
    There are ample (hundreds of) examples on the forum of formatting via VBA. Have you searched?

    Yes and I'll search better/longer next time. Thank you.

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Conditional formatting with 6 conditions?

    Team, there is always room to learn something new. Thanks.


    proepert,

    Here is a VBA solution using the Worksheet_Change Event.

    See the attached workbook "Worksheet_Change Event - Conditional formatting with 6 conditions - proepert - SDG11.xls".

    Detach/open the workbook and make changes to range B1:B6.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  8. #8
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Re: Conditional formatting with 6 conditions?

    Thank you all.

    I'm struggling to understand the AND command. Yes I have solved my question but still do not fully understand the special characters in the command. Yes I'm going to get a book.

    Stan, thank you very much.
    Last edited by proepert; 01-24-2010 at 02:53 AM.

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Conditional formatting with 6 conditions?

    proepert,

    AND() returns TRUE when all components in it are true.

    You want to check if

    1. Cell B1 has a valid value from its pull down list, no other value, and not empty.
    2. Cell B2 has an integer, no decimal places allowed, and not empty.
    3. Cell B3 has a valid value from its pull down list, no other value, and not empty
    4. Cell B4 is not empty.
    5. Cell B5 has a three decimal place number greater than zero.
    6. Cell B6 has a single letter from A-Z only.

    individually, these checks can be put into Excel statements that deliver true or false, like

    1. =MATCH(B1,names,0)>0
    2. =B2=INT(B2)
    3. =MATCH(B3,cities,0)>0
    4. =AND(B4<>"",B4<>0)
    5. =LEN(B5)-FIND(".",B5)=3
    6. =AND(CODE(UPPER(B6))>=65,CODE(UPPER(B6))<=90,LEN(B6)=1)

    All these six checks return either TRUE or FALSE

    You want the conditional format to apply when all six conditions are True, so

    =AND(1=TRUE, 2=TRUE, 3=TRUE ... 6=TRUE)

    replace each parameter in the mockup AND() statement above with the formulas numbered 1-6, and you'll arrive at this formula: (breaking it down indo individual lines for clarity)

    Please Login or Register  to view this content.
    Only if all components of the AND() statement evaluate as true, will the AND() function return a TRUE and the conditional format will be applied.

    Does that make it clearer?
    Last edited by teylyn; 01-24-2010 at 03:32 AM. Reason: dypo

  10. #10
    Forum Contributor
    Join Date
    11-17-2009
    Location
    PA USA
    MS-Off Ver
    Excel 2000
    Posts
    184

    Re: Conditional formatting with 6 conditions?

    So condition #4 and condition #6 have the AND() statement in them, this is what was confusing me. Yes, its much clearer now.

+ 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