Formatting Issues

Link Excel Calendar Cells to Dates with Conditional Formatting

Huda QurayshiHuda Qurayshi Nov 18, 2026 872 views

Question details

Create a dynamic calendar whose cells correspond to dates and update when the selected month or year changes.

Link Excel Calendar Cells to Dates with Conditional Formatting
Product
Microsoft Excel
Device & OS
not provided
Scenario
A calendar uses separate month and year selections and needs cells below displayed days to refer to the correct dates.
Observed behavior
Calendar dates and their associated formatting should update automatically when the selected month, year, or event dates change.
Before you start

Choose cells for a numeric year and month, and make sure any dates you want to highlight are real Excel dates rather than text. The example below uses B1 for the year, B2 for the month number, and AH2:AH100 for dates to highlight.

Solution 1Recommended

Build a date-based calendar and highlight matching cells

Use this single-row calendar layout to link cells beneath each day to real dates and highlight dates in a separate list.

1
Enter the year and month

Enter a four-digit year in B1 and a month number from 1 to 12 in B2. For example, enter 2026 and 2 for February 2026.

2
Create the date headers

Enter =DATE($B$1,$B$2,1) in B3. Enter =IF(B3="","",IF(MONTH(B3+1)=$B$2,B3+1,"")) in C3, then drag C3 across through AF3. Select B3:AF3 and use Home > Number > More Number Formats > Custom with the format d to display only day numbers.

3
Link the cells below

Enter =IF(B$3="","",B$3) in B4 and drag it across through AF4. Format B4:AF4 as dates if you want to display the linked dates; the formulas return blank for days outside the selected month.

4
Add dates to highlight

Enter the dates you want to highlight as real dates in AH2:AH100. Use dates without time values so they match the calendar dates.

5
Create the formatting rule

Select B4:AF4, then choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter =AND(B$3<>"",COUNTIF($AH$2:$AH$100,B$3)>0), choose a format, and select OK.

Build a date-based calendar and highlight matching cells
What the rule does: Conditional formatting changes the appearance of matching cells; it does not create dates or event entries. Change B1 or B2 to update the calendar, and update the date list in column AH to change which cells are highlighted.
Try it in WPS Office

Create a dynamic calendar in WPS Spreadsheets

Use date formulas and a conditional formatting rule in WPS Spreadsheets to link calendar cells to the selected month and highlight matching dates.

  1. 1. Set the month and year: Open WPS Spreadsheets and enter a year in B1 and a month number from 1 to 12 in B2.
  2. 2. Create the calendar dates: Enter =DATE($B$1,$B$2,1) in B3. In C3, enter =IF(B3="","",IF(MONTH(B3+1)=$B$2,B3+1,"")) and drag the formula through AF3. Format B3:AF3 with the custom number format d.
  3. 3. Link the row below: Enter =IF(B$3="","",B$3) in B4 and drag the formula across through AF4.
  4. 4. Enter event dates: Enter the dates to highlight in AH2:AH100 as real dates without time values.
  5. 5. Highlight matching dates: Select B4:AF4 and open Home > Conditional Formatting > New Rule. Choose a formula-based rule, enter =AND(B$3<>"",COUNTIF($AH$2:$AH$100,B$3)>0), select a format, and confirm the rule.
Update calendar dates by changing the month or yearHighlight dates from a separate event listOpen and save Microsoft Excel XLSX filesWork with formulas and formatting in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why should calendar headers be real dates instead of text?

Real dates let formulas compare the full day, month, and year. Use DATE(year,month,day) to create a date, then apply the custom number format d to display only its day number.

Why are dates after the end of the month blank?

The header formula checks whether the next date is still in the selected month. If it is not, it returns a blank instead of displaying a date from the following month.

Why is a date in my event list not highlighted?

Check that the value in AH2:AH100 is a real date with the same year, month, and day as the calendar header. Text values and dates containing times may not match; convert them to date-only values and check the conditional formatting rule.

Can I highlight several rows below each day?

Yes. Select the additional rows, such as B4:AF6, when creating the rule and use the same formula with B$3. The fixed row reference makes each cell check the date header in its own column.