+ Reply to Thread
Results 1 to 6 of 6

Conditional formatting based on dates (month and year specifically)

  1. #1
    Registered User
    Join Date
    08-22-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Office 2010
    Posts
    30

    Conditional formatting based on dates (month and year specifically)

    I am trying to create some conditional formatting that will highlight a cell yellow if the month and year matches the current month and year, and will highlight blue if the month/year is equal to NEXT month. I've figured out how to get the cell to highlight if it matches the current month/year, but not the second part, where it will highlight blue if the date matches next month.

    The formula I have used to highlight if the month/year matches the current month/year is
    =(DATE(YEAR($Q$2),MONTH($Q$2),1)-DATE(YEAR(G4),MONTH(G4),1)=0)
    where cell Q2 contains the formula =TODAY() and cell G4 is the date I wish to compare.

    However, I cannot figure how to alter this formula to get cell G4 to highlight blue if and only if the year and month match NEXT month (so in this case April 2015 but not may 2015).
    =(DATE(YEAR($Q$2),MONTH($Q$2),1)-DATE(YEAR(G4),MONTH(G4),1)=-1 doesn`t work.

  2. #2
    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,929

    Re: Conditional formatting based on dates (month and year specifically)

    For the "same" month, try this instead...
    =EOMONTH(G4,0)=EOMONTH(Q2,0)

    For "next" month...
    =EOMONTH(G4,0)=EOMONTH(Q2,1)
    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

  3. #3
    Registered User
    Join Date
    08-22-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Office 2010
    Posts
    30

    Re: Conditional formatting based on dates (month and year specifically)

    That worked perfectly and made it simpler for the other formula as well. Thank you!

  4. #4
    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,929

    Re: Conditional formatting based on dates (month and year specifically)

    Happy to help

  5. #5
    Registered User
    Join Date
    08-22-2014
    Location
    Kelowna, Canada
    MS-Off Ver
    Office 2010
    Posts
    30

    Re: Conditional formatting based on dates (month and year specifically)

    I tried adding reputation for you but its telling me I have to spread some reputation to others before I can give you more. Thanks again!

  6. #6
    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,929

    Re: Conditional formatting based on dates (month and year specifically)

    Thats OK, thanks for trying

+ 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] Conditional Formatting for dates to expire in 1 year
    By rileytto in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-02-2020, 03:09 PM
  2. [SOLVED] Conditional Formatting based on calculated future dates (month only, ignore day and year)
    By Nitsirk82 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-27-2014, 06:42 PM
  3. [SOLVED] formatting dates to automatically extract Year and month
    By alexcrofut in forum Excel General
    Replies: 1
    Last Post: 01-23-2014, 03:09 PM
  4. Conditional Format based on Year & Month.
    By SpiritedAway in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-06-2013, 06:02 PM
  5. Based on col dates create col of dates for the first day of that same month and year
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2011, 09:32 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