A quick calendar is a graphical display of the days of any month in a year, arranged in seven columns (Sunday through Saturday) and as many rows as needed. A quick calendar can be useful for planning events, tracking deadlines, or simply checking the dates. In this article, we will show you how to create a quick calendar in Excel with one formula, using the SEQUENCE function and some other helper functions. We will also explain the basic theory behind the formula, and provide a detailed example with real data.
The key function in our formula is SEQUENCE, which returns an array of sequential numbers in a specified range. For example, SEQUENCE(3,4) returns a 3-by-4 array of numbers from 1 to 12. The SEQUENCE function has four arguments: rows, columns, start, and step. The rows and columns arguments specify the size of the array, the start argument specifies the first number in the array, and the step argument specifies the increment between the numbers. The start and step arguments are optional, and default to 1 if omitted.
To create a quick calendar, we need to use the SEQUENCE function to generate an array of dates for the given month and year. We also need to use some other functions to align the dates in the correct columns, and to display only the dates that belong to the month. These functions are:
- DATE: This function returns the serial number that represents a specific date. The DATE function has three arguments: year, month, and day. For example, DATE(2024,2,5) returns the serial number for February 5, 2024.
- WEEKDAY: This function returns a number from 1 to 7 that represents the day of the week of a given date. The WEEKDAY function has two arguments: serial_number and return_type. The serial_number argument is the date to evaluate, and the return_type argument specifies which day is considered the first day of the week. The return_type argument is optional, and defaults to 1 if omitted, which means Sunday is the first day of the week. For example, WEEKDAY(DATE(2024,2,5)) returns 3, which means Tuesday.
- EOMONTH: This function returns the serial number for the last day of the month that is a specified number of months before or after a given date. The EOMONTH function has two arguments: start_date and months. The start_date argument is the date to evaluate, and the months argument is the number of months before or after the start_date. For example, EOMONTH(DATE(2024,2,5),0) returns the serial number for February 29, 2024, which is the last day of the same month as the start_date. EOMONTH(DATE(2024,2,5),-1) returns the serial number for January 31, 2024, which is the last day of the previous month.
Procedures
To create a quick calendar in Excel with one formula, follow these steps:
- In a cell, enter the year and month for which you want to create the calendar. For example, enter 2024 in cell A1 and 2 in cell A2 for February 2024.
- In another cell, enter the following formula:
=SEQUENCE(6,7,DATE(A1,A2,1)-WEEKDAY(DATE(A1,A2,1))+1)
This formula returns a 6-by-7 array of dates starting from the first day of the month, and subtracting the weekday number of the first day of the month to align the dates in the correct columns. For example, for February 2024, the first day of the month is a Wednesday, which has a weekday number of 4. Therefore, the formula subtracts 4 from the date of February 1, 2024, and returns the date of January 28, 2024 as the first element of the array. The formula then increments the dates by 1 until the end of the array. - Select the cell with the formula and six cells to the right, and seven cells below, to create a 7-by-8 range. Press Ctrl + Shift + Enter to enter the formula as an array formula. You should see the dates displayed in the range, with some dates from the previous and next month.
- To display only the dates that belong to the month, select the range with the dates, and go to the Home tab, click Conditional Formatting, and select New Rule. In the New Formatting Rule dialog box, select Use a formula to determine which cells to format, and enter the following formula in the Format values where this formula is true box:
=MONTH(A1)<>MONTH($A$1)
This formula checks if the month of the date in the cell is different from the month of the date in cell A1, which is the month we want to display. If true, it applies the formatting we specify in the next step. - Click the Format button, and go to the Number tab. Select Custom from the Category list, and enter
;;;
in the Type box. This custom format hides the value in the cell, but does not affect the underlying date. Click OK to close the Format Cells dialog box, and click OK again to close the New Formatting Rule dialog box. You should see only the dates that belong to the month displayed in the range, and the other dates hidden. - To format the calendar, you can apply any style, color, border, or font you like to the range. You can also add labels for the month, year, and days of the week above the dates. For example, you can use the following formula in cell A9 to display the month and year:
=TEXT(DATE(A1,A2,1),"mmmm yyyy")
and use the following formula in cell A10 to display the day of the week:=TEXT(SEQUENCE(1,7),"ddd")
Example
To illustrate the steps above, let’s create a quick calendar for February 2024 using the formula and formatting we described. Here is the result:
February 2024 | ||||||
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 |
As you can see, the formula displays the dates of February 2024 in the correct columns, and hides the dates from the previous and next month. The formatting makes the calendar easy to read and use.
Other Approaches
The formula we used to create the quick calendar is not the only way to achieve the same result. There are other approaches that use different functions or methods to generate the dates and format the calendar. For example, some alternative formulas are:
=SEQUENCE(6,7,EOMONTH(DATE(A1,A2,1),-1)+1-WEEKDAY(EOMONTH(DATE(A1,A2,1),-1)))
This formula uses the EOMONTH function to get the last day of the previous month, and adds 1 to get the first day of the current month. It then subtracts the weekday number of the last day of the previous month to align the dates in the correct columns.=SEQUENCE(6,7,DATE(A1,A2,1)-MOD(WEEKDAY(DATE(A1,A2,1))-1,7))
This formula uses the MOD function to get the remainder of dividing the weekday number of the first day of the month by 7. It then subtracts this remainder from the date of the first day of the month to align the dates in the correct columns.
You can also use different methods to hide the dates from the previous and next month, such as using an IF function to return an empty string, or using a custom number format that displays only the day of the month. You can also use different methods to format the calendar, such as using a table style, or using a pivot table.