+ Reply to Thread
Results 1 to 4 of 4

Cond. Formatting rule works differently than And statement with multiple conditions

  1. #1
    Registered User
    Join Date
    08-04-2010
    Location
    United States
    MS-Off Ver
    Office 365 for windows
    Posts
    62

    Unhappy Cond. Formatting rule works differently than And statement with multiple conditions

    Hello. I have two sets of And statements with multiple conditions. They work properly when used in the worksheet as formulas checking dates.

    When they are used in conditional formatting the conditional formatting does not work the same way and the wrong dates are highlighted.

    The first rule should work this way with dates in column A beginning with A2:

    If current month?s day number is >=1 and <= 15, highlight the dates in Column A >=16th to EOM of the previous month.
    If I put my formula in B2 and drag down. True and false seem to match the expected outcome for the corresponding dates in column A.

    =AND(DAY(TODAY())>=1,DAY(TODAY())<=15,A2>=DATE(YEAR(A2),MONTH(A2-1),16),A2<=EOMONTH(TODAY(),-1))

    Using the same exact formula pasted into the conditional formatting highlights days 15-29 instead of 16-eom but using the formula shows the correct true and false next to the dates.

    The second formula should work similarly but has the same problem: If the current month?s day number is >=16 and <= EOM day number, highlight the date 1-15 of the current month.

    =AND(DAY(TODAY())>=16,DAY(TODAY())<=DAY(EOMONTH(TODAY(),0)),A2>=DATE(YEAR(TODAY()),MONTH(TODAY()),1),A2<=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(15)))

    When using the exact same formula in conditional formatting It highlights last day of previous month to the 14th day of current month but it seems the correct true and false output is next to the proper dates as expected.

    I sincerely have no idea where I am going wrong. If anyone can let me know where I am going wrong I would really appreciate it.
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Cond. Formatting rule works differently than And statement with multiple conditions

    Your formula rule refers to cell A2, although the range for conditional formatting is set for A$1 onwards (well, with a break in the middle). Consequently, the CF rule for cell A2 is actually looking at the next cell, so you need to adjust the Refers To range to start with A$2.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    08-04-2010
    Location
    United States
    MS-Off Ver
    Office 365 for windows
    Posts
    62

    Re: Cond. Formatting rule works differently than And statement with multiple conditions

    Ugh thank you. Too many hours looking at too much code. ><

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Cond. Formatting rule works differently than And statement with multiple conditions

    Glad to have helped - thanks for the rep.

    Pete

+ 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. Replies: 2
    Last Post: 06-27-2023, 11:04 PM
  2. Conditional formatting rule how to set with two or two more conditions
    By davidchin777 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-23-2019, 05:52 PM
  3. Replies: 1
    Last Post: 07-02-2018, 07:32 PM
  4. [SOLVED] Multiple conditions in One rule of Conditional Formatting
    By tanmayjajoo in forum Excel General
    Replies: 10
    Last Post: 08-13-2014, 12:53 PM
  5. Four rule statement with multiple criterias (Formula?, macro?, IDK??)
    By bwalling6 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2013, 04:49 PM
  6. [SOLVED] Formula help required to enable conditional formatting of cells that meet multiple cond.
    By Barbara Excel in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-30-2012, 01:34 PM
  7. Cond. Formatting - Multiple Values
    By elfiky in forum Excel General
    Replies: 1
    Last Post: 03-16-2009, 07:36 PM

Tags for this Thread

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