+ Reply to Thread
Results 1 to 25 of 25

Conditional Formatting Days in a Dynamic Calendar

  1. #1
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Conditional Formatting Days in a Dynamic Calendar

    Hi

    I have a question that I think is related to conditional formatting.

    I have created a dynamic calendar. The dates rearrange as you change the year. The week counter has been corrected. The next item I wanted to do is have certain days change color depending on their position in the month. To start with I would like to have every 2nd Wednesday highlighted in orange. Start in 2021, date would be Jan 6th then Jan 20, then Feb 3, ....., Dec 22. It's not that date that is important but every second Wednesday. Then when the year changes this formatting changes to reflect so in 2022 it would be Jan 5th then Jan 19th etc.
    In the sample calendar I have just filled the fill with orange
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,811

    Re: Conditional Formatting Days in a Dynamic Calendar

    As the position in the calendar will be the same regardless of the year, I see no point at all in using CF for this. CF should only be used where nothing else will work as it can begin to slow down your workbook if overused.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Volunteer organiser & photographer with the Sutton Hoo Ship's Company: https://saxonship.org/
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    The position changes from year to year on the calendar because months change from having 4 weeks to 5 week or 5 weeks to 6 weeks or visa versa

    Example: May starts on Saturday, week 17 and ends on Monday, week 22, a total of 6 weeks. In 2022 May starts on Sunday, week 18 and ends on Wednesday, week 22, only 5 weeks and that changes the position of the cell.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,811

    Re: Conditional Formatting Days in a Dynamic Calendar

    OK - I see. Let me have a think.

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Conditional Formatting Days in a Dynamic Calendar

    Try CF formula below, applied to cells C7:I12 and L7:R12:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Conditional Formatting Days in a Dynamic Calendar

    Change to:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    I copied the formula over and the attached file shows what I get. It does not appear to work unless I am doing something wrong.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Conditional Formatting Days in a Dynamic Calendar

    Sorry.. misread your question.. it's every second Wednesday:

    For January table:=C7=AGGREGATE(15,6,C$7:C$12/(MONTH(C$7:C$12)=MONTH(C$8)*(TEXT(C$7:C$12,"ddd")="Wed")),2)
    For February table:=L7=AGGREGATE(15,6,L$7:L$12/(MONTH(L$7:L$12)=MONTH(L$8)*(TEXT(L$7:L$12,"ddd")="Wed")),2)

  9. #9
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    Thanks josephteh

    I did notice that and tried the change. It does high light the second Wednesday, Jan 13, but only that one. I need it to start on and highlight Jan 6 and then every other Wednesday after, then change as the year change.
    I also correct Feb formula to reference L7 to L12 and changed the 3 to a 2, it highlights Feb 3rd and Feb 10th, the 3rd is correct but not the 10th.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    In D4

    =DATE($E$2,MONTH(C$4&0),1)+7-WEEKDAY(DATE($E$2,MONTH(C$4&0),1)+3)

    This is date of first Wednesday of the month

    in CF

    =OR(C7=$D$4,C7=$D$4+14)

    Repeat for all months.

    You can hide the first formula elsewhere (or set Font colour to white)
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  11. #11
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    Thank you JohnTopley

    It started out right but there are still a few glitches. The first starts in March of 2021. If we are highlighting every second Wednesdays should not March 31st be highlighted? If you move through the years, such as 2023, it has the first 3 Wednesdays highlighted.

  12. #12
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Conditional Formatting Days in a Dynamic Calendar

    Quote Originally Posted by Conabear View Post
    Thanks josephteh

    I did notice that and tried the change. It does high light the second Wednesday, Jan 13, but only that one. I need it to start on and highlight Jan 6 and then every other Wednesday after, then change as the year change.
    I also correct Feb formula to reference L7 to L12 and changed the 3 to a 2, it highlights Feb 3rd and Feb 10th, the 3rd is correct but not the 10th.
    How can Jan 6 be second Wednesday of Jan?

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    Yes . March 31st should be highlighted,

    Try

    =AND(MONTH(C7)=MONTH($D$4),OR(C7=$D$4,C7=$D$4+14,,C7=$D$4+28))

    This assumes 1st/3rd/5th Wednesday WITHIN a month. If you need to treat the year as a contiguous set of Wednesdays then the above will not apply.

    (May be possible using WEEKNUM ????)

    The layout of the calendar does not lend itself the an easy CF formula for considering the year as a whole.
    Attached Files Attached Files
    Last edited by JohnTopley; 09-29-2021 at 03:04 AM.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,811

    Re: Conditional Formatting Days in a Dynamic Calendar

    Quote Originally Posted by josephteh View Post
    How can Jan 6 be second Wednesday of Jan?
    I agree - it can’t be!

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    If you want contiguous 2 weeks:

    =AND(MONTH(C7)=MONTH($D$4),MOD((C7-$D$4),14)=0)

    Adjust BOLD for each month

    I cannot test for others years as I don't have 365 and changing YEAR results in #NAME errors ( formulae not in Excel 2010))
    Last edited by JohnTopley; 09-29-2021 at 04:52 AM.

  16. #16
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    Dec 23 of 2020 was the previous selected Wednesday then two weeks later we hit Jan 6th 2021, this is why I need it to run year to year as well. The same will happen next year, last Wednesday that would be selected in 2021 will be Dec 22 then, two weeks later, Jan Jan 5 of 2023, which happens to be the first Wednesday of Jan. in 2023.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,811

    Re: Conditional Formatting Days in a Dynamic Calendar

    I think the issue we have is this idea of the 'second Wednesday' of each month. It's not really that at all, is it?

  18. #18
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    See post #15
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    Ok I copy this new formula into my test calendar, it does highlight every second Wednesday for each month but not every second Wednesday consecutively through the year , maybe I've asked the question wrong.

    I need every second Wednesday in the calendar to be highlighted, starting with Jan 6, Jan 20, Feb 3, Feb 17, Mar 3, Mar 17, Mar 31, etc....

    Also if this is not possible with CF, is there any other solutions?

    P.S.
    I also attached an entire calendar year.
    Attached Files Attached Files
    Last edited by AliGW; 09-29-2021 at 10:18 AM. Reason: PLEASE don't quote unnecessarily!

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    Formulae for February

    =AND(MONTH(L7)=MONTH($M$4),OR(L7=$M$4,L7=$M$4+14,,L7=$M$4+28))

    Mea Culpa: I did not highlight Month change in my previous post: similar for all months.

    However, if you had checked the posted file (which was correct!) you would have spotted this.
    Last edited by JohnTopley; 09-29-2021 at 10:20 AM.

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    Alternative the CF is VBA

  22. #22
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    Thanks JohnTopley

    Just after I posted a found the mistake, I'm in the process of correcting. Looking good so far. Thank you.

  23. #23
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    See attached - Sheet1.

    If you base the MOD of first Wednesday of 2021 ( 6th Jan) then all following years should follow.

    =AND(MONTH(C7)=MONTH($D$4),MOD((C7-$D$4),14)=0)

    $D$4 is 6th jan 2021 so FIX this in another cell and change the bold to this new cell reference e.g B2 in your calendar
    Attached Files Attached Files
    Last edited by JohnTopley; 09-29-2021 at 11:44 AM.

  24. #24
    Registered User
    Join Date
    09-24-2021
    Location
    Edson, AB, Canada
    MS-Off Ver
    365
    Posts
    11

    Re: Conditional Formatting Days in a Dynamic Calendar

    The last suggestion that JohnTopley gave fixed the issue and the calendar works perfect so thank you everyone for all your help.

  25. #25
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,748

    Re: Conditional Formatting Days in a Dynamic Calendar

    You're welcome.

+ 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 Format Non Calendar Days (gray out)
    By BillySpivy in forum Excel General
    Replies: 4
    Last Post: 06-21-2021, 10:43 AM
  2. [SOLVED] Conditional formating cells in a dynamic anual calendar
    By Konta in forum Excel General
    Replies: 4
    Last Post: 09-24-2019, 11:19 AM
  3. Calendar conditional formatting
    By heb1145 in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 08-19-2019, 09:30 AM
  4. [SOLVED] Change All Conditional Format Fills for Days in Calendar Months
    By xjohnson in forum Excel General
    Replies: 3
    Last Post: 11-19-2018, 10:25 AM
  5. Replies: 2
    Last Post: 10-03-2016, 08:35 AM
  6. [SOLVED] Conditional Formatting - certain days in a calendar
    By keith6292 in forum Excel General
    Replies: 2
    Last Post: 09-04-2013, 12:17 PM
  7. Conditional Formatting Dynamic Calendar
    By soubriquet in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2013, 01:56 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