Automatically create a calendar with a function|How to create a perpetual calendar that includes holidays (with templates) | Excel

The finished calendar (red for holidays, green for company holidays, blue for Saturdays) Excel Macro (VBA)
The finished calendar (red for holidays, green for company holidays, blue for Saturdays)
The article contains advertisements.

When creating a calendar or schedule each month, do you always re-enter the dates, check the holidays, and color each day one by one?

In this article,Just change the year and monthAnd that includes the date, day of the week, holidays, and company holidays.Automatic perpetual calendar that switches automaticallyI will introduce how to make it. It starts on the 16th and ends on the 15th.Also available for final payment deadlinesI will do so.

If you follow this article and build it in order, you can make a perpetual calendar, but the finished product will be very large.TemplatesFor those who just want itAt the end of the articleにDownload linkPlease download it from there as it is listed with the suffix "zip".

Public holidaysIt is the list published by the Cabinet Office, and you don't have to do anything to access it.Excel reads it directlyEven when the year changes, the next year's holiday remains the same.Just open the Excel fileThen I'll get in.

The finished calendar (red for holidays, green for company holidays, blue for Saturdays)
The finished calendar (red for holidays, green for company holidays, blue for Saturdays)

I also explain it in the video.

*The function to import holidays from the web requires the Windows version of Excel.
For Mac users, please see the "Notes" section later.

  1. Step 1: Automatically enter the date and day of the month and year, as well as the time and time zone.
    1. Create a settings section
    2. Calculating the start and end dates
    3. Enter the date
    4. Enter the day of the week
    5. The header is also adjusted to match the settings section.
  2. Step 2: Automatically load the list of holidays and display the names of the holidays
    1. Loading the list of national holidays of the Cabinet Office
      1. 1. Click "From the Web" in the "Data" tab.
      2. 2. Paste the address into the URL field and press "OK".
      3. 3. The content that has been read will be displayed, so please make sure that the name of the holiday is read correctly.
    2. When the characters become distorted
    3. Check the title and date to ensure that it is loaded correctly
    4. Make the latest list every time you open the file
      1. 1. Open the "Connection Properties"
      2. 2. Enable "Update data when opening files"
    5. Display the name of the holiday in the calendar
  3. Step 3: Automatically fill in the company's holidays and regular business days.
    1. Create a "Company Holidays" sheet
    2. Add the company's holidays and non-working days to the queue for public holidays and weekends.
    3. Create a column of categories
    4. Apply color and borders with conditional formatting
    5. Be careful with the order of the rules
    6. Hide the column of categories
  4. important point
    1. The schedule is written on a one-sheet per month basis.
    2. When opened on another computer, a yellow band appears.
    3. In Mac Excel, "From the Web" is not available
  5. When created in Google Sheets
    1. Method 1: Load it using the IMPORTDATA function (easy)
    2. Method 2: Read the Cabinet Office list using Apps Script (certainly)
    3. Different from Excel
  6. Summary
  7. Downloading the completed file (template)

Step 1: Automatically enter the date and day of the month and year, as well as the time and time zone.

The calendar is as follows: one line for each day, with 31 lines from the sixth to the 36th.

Calendar format
LocationThe contents
B rowDate
C columnDays of the week
Row DPublic holidays and days off
Row E and Row FSchedule and notes (written by hand)
H column, I columnSettings section (year, month, closing date, regular holidays, starting date and ending date)

If you already have a handmade calendar, please replace the columns with the corresponding ones from that calendar.

Create a settings section

Create a settings field to the right of the calendar. Enter the item name in the H column and the value in the I column.

Settings section
行H columnRow I (example)
6年2027
7月1
8Deadline15
9Regular holidaysWednesday
10Starting date(Calculated in the formula)
11End date(Calculated in the formula)

I6 to I9Paint it yellow and make it look like "only touch here." This way, you can see at a glance which part needs to be changed and it won't break the ceremony if you hand it over to someone else.

Make it possible to choose from a list of days for the month, the closing date, and the regular business hours.

The specific setup method is as follows:
First select the cell you want to set the input rules for, then click on the "Data" tab > "Input rules for data".

Input rule settings

Select "List" from the "Input value type" menu that appears.

Select the list

Enter the following in the "Original value" field and click "OK".

List input

For the other items, please enter them as follows:

CellThe original value
I7 (month)1,2,3,4,5,6,7,8,9,10,11,12
I8 (Deadline)Last day, 5, 10, 15, 20, 25
I9 (regular holiday)None, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

*The "Data input rules" will open even if you press Alt → A → V → V.

Calculating the start and end dates

To coincide with the deadline, this calendarFrom what day to what dayWe calculate the number first.

Setting the start date

This is the formula for the starting date (I10).

=IF($I$8="Last Day",DATE($I$6,$I$7,1),DATE($I$6,$I$7-1,$I$8+1))

If the deadline is "the last day of the month," it is the 1st of that month; otherwise, it is the "next day of the deadline of the previous month." For the January deadline on the 15th, it will be December 16, 2026.

DATE functionThis is a function that creates a date from the three digits of the year, month, and day. If you write "month-1" in the month, it will be the previous month. In January, it will be the 0th month, but the DATE function will calculate 0th month as "the 12th month of the previous year".

Enter the end date

This is the formula for the end date (I11).

=IF($I$8="末日",DATE($I$6,$I$7+1,0),DATE($I$6,$I$7,$I$8))

For the end of the month, it is the last day of that month; otherwise, it is the closing date of that month.
The day of the DATE functionIf you enter 0, it will be the last day of the previous month.That means "the 0th of the next month" is the "last day of the current month." The dates of February 28 and February 29 are automatically displayed.

I10 and I11 will set the display format to date.

Enter the date

The B6 displays the starting date.

=$I$10
Functions are available in B6

In B7, insert the following formula and copy it down to B36.

=IF(B6="","",IF(B6+1>$I$11,"",B6+1))

It's a formula that adds 1 to the date above and clears the space if the end date is exceeded.
Months with fewer days like February will have empty rows left over.

If all the formatting is copied as well, you can click the icon that appears in the bottom right corner and select "Copy without formatting" to paste only the function.

Copy without formatting

Enter the day of the week

Insert the following formula into C6 and copy it to C36.

=IF(B6="","",TEXT(B6,"aaa"))
Enter the function for C6

There are several ways to display the day of the week, but for this example,TEXT functionWe decided to use it.

By formatting the date as "aaa" using the "TEXT function," it is converted to a weekday character like "Mon." When you use "aaaa," it becomes "Friday."

Even if you set the display format to "aaa" in the cell formatting settings, you can still display the days of the week; however, if you convert them to text using the TEXT function, the formulas for determining the regular holidays and weekends will be shorter.

The header is also adjusted to match the settings section.

The header at the top of the table is also created from the settings section.

The function in the title
Cell式display
B2=$I$6&"year"2027
D2=$I$7&"Monthly"March issue
E2=IF($I$10="","",TEXT$I$10,"yyyy/m/d")&" ~ "&TEXT$I$11,"yyyy/m/d"))2027/2/16 ~ 2027/3/15

If you just connect the dates with & symbols, it will result in numbers like "46372". In Excel, dates are numbers because they are numbers.TEXT functionThen I put the text in the form of "2026/12/16", and then I connect them together.

Function 2 in the title

Now, if you change the month or the due date, the date, day, and heading will be switched. The name and color of the holiday will be automatically set in the next step.

Step 2: Automatically load the list of holidays and display the names of the holidays

Holidays change slightly each year. The dates for Spring Equinox and Autumn Equinox vary from year to year, and there are also holidays that are determined as "the second Monday of January," such as Adult Day.

If you manually paste the list of holidays, you will have to re-paste it every year. If you forget, the holidays will no longer have colors when you change the year. Therefore, the list of holidays is automatically loaded from the Cabinet Office data.

Loading the list of national holidays of the Cabinet Office

On the page titled "National Holidays for the Public," the Cabinet Office is publishing a list of national holidays from 1955 to the following year in a CSV file.

Load this file directly from Excel's "From the Web" option.

1. Click "From the Web" in the "Data" tab.

From the web

2. Paste the address into the URL field and press "OK".

https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv
Enter the URL

3. The content that has been read will be displayed, so please make sure that the name of the holiday is read correctly.

Click on "Data conversion"

Note: "From the web" will open even if you press Alt → A → F → W in that order.

When the characters become distorted

Depending on the computer or file, the name of the holiday may be displayed in a character that cannot be read.
The Cabinet Office files are created in a format called "Shift JIS," and if you read it in a different format, it will become illegible.

In that case, open the "original file" on the screen and
Choose "932: Japanese (Shift JIS)".

Change the character code

This is usually the cause even when the CSV file exported from the company's system is read in and converted to a readable format.

Check the title and date to ensure that it is loaded correctly

When you press "Convert Data," the Power Query editor opens. Here, you can:

  • Is the first line the headline?
  • Is the first column showing the date (is there a calendar mark to the left of the column heading)?

Let's check it out.

Is the first line the title?

Both usually have Excel doing the work automatically.

Don't press "Use first line as header" here. It's already being used as a header, so pressing it will turn the first line from New Year's Day 1955 into a header.

If there are no problems, click "Close and Load."

Close and read in

The list of holidays is included as a table in the new sheet.
For easy understanding, I will change the name of the sheet to "Holiday".

Change the seat name to celebrate a holiday
列TitleThe contents
A columnNational public holidays and days off2027/1/1 etc.
B rowNational Public Holidays and Public Holidays NamesNew Year's Day, etc.

The name of the table will be "syukujitsu" from the file name. Please remember it as we will use it in the formula later.

Make the latest list every time you open the file

1. Open the "Connection Properties"

With the cell in the table selected somewhere,
Click the ▼ button under "Update All" in the "Data" tab and click "Connection Properties."

Open the connection properties

2. Enable "Update data when opening files"

The "Query Properties" screen will open, so check "Update data when opening file" and click "OK."

Check to update when opening the file

This way, every time you open a file, you’ll have the latest list of national holidays loaded again. The National Diet Library compiles a list of national holidays for the following year around February each year. If you don’t do anything, the next year’s holidays will be included automatically.

Even though it says it will load every time you open it, it only takes about 1 to 2 seconds to load. Moreover, when it opens, only updates are being processed in the background, so it won’t take long to load.

Display the name of the holiday in the calendar

Insert the following formula in D6 and copy it to D36.

=IF(B6="","",IFERROR(INDEX(syukujitsu[National Holidays and Public Holidays Names],MATCH(B6,syukujitsu[National Holidays and Public Holidays Month and Date],0)),""))
Enter the function
PartiallyWhat they are doing
MATCHFind out what the B6 date is among the list of holidays.
INDEXFrom the list of holiday names, find the name that comes after the last one.
IFERRORIf it doesn't show up on non-holiday days, it will be an error, so I'll leave it empty.

When selecting the list of holidays during the ceremony, click the column in the "Holidays" sheet.

Not specifying cells like "B:B",syukujitsu[National holidays and days off names]Enter the table name and column name as in the example.

If you specify it in the column of the table, even if the list gets longer due to the upcoming holidays, you don't need to adjust the schedule.

The holidays are displayed

When the year changes, it switches to the holiday of that year.

Step 3: Automatically fill in the company's holidays and regular business days.

Finally, you can have the company's holidays and regular business days displayed, and it will automatically assign colors to them for holidays, weekends, and public holidays.

Create a "Company Holidays" sheet

Create a new sheet and name it "Company Holidays."

Write the date in column A and the name of the day off in column B.

Set the company's vacation policy

During the holidays, I write one line per day.
For the rest of the year, you can just add it up as you go along.

Add the company's holidays and non-working days to the queue for public holidays and weekends.

Substitute the D6 expression entered in step 2 into the following expression to copy it to D36.

=IF(B6="","",IFERROR(INDEX(syukujitsu[National Holidays & Holidays Names],MATCH(B6,syukujitsu[National Holidays & Holidays Months],0)),IFERROR(INDEX(Company Holidays!$B:$B,MATCH(B6,Company Holidays!$A:$A,0)),IF(C6&"Day"=$I$9,"Regular Holidays",""))))
Enter the function

Search in the following order and display the found items.

  1. If it is on the list of public holidays, the name of the holiday
  2. If you don't have it, put the name of the vacation on the "Company Holidays" sheet.
  3. If that is not the case, then set the "fixed holiday" to the same day as the fixed holiday in the settings section.
Settings section

The day of the week in column C is a single letter like "Wednesday," so we add "Wednesday" at the end and compare it to "Wednesday" in the settings section.

Create a column of categories

Before applying colors, create a "category" column in the K column on the right side of the calendar.

Insert the following formula into K6 and copy it to K36.

=IF(B6="","",IF(COUNTIF(syukujitsu[National Holidays and Public Holidays],B6)>0,"Holiday",IF(D6"","Company",")))
Added to K-line

For public holidays, it will be "Public Holiday", and for company holidays or fixed days off, it will be "Company".

In conditional formatting formulas, if you directly reference other sheets, depending on the version of Excel,"References to other worksheets cannot be used"It says "Not available", so I can't use it.
The same seatIf you set the K column to show, it will work in any version.

Apply color and borders with conditional formatting

The colors that were painted with your hands and the borders that were drawn with your hands will be erased all together for now.

Delete all formatting

Select "B6 to F36" to set the format.

Delete the formatting temporarily

Click "Conditional Formatting" in the "Home" tab, then "New Rule."

Create new rules for the format

Select "Determine which cells to format using formulas," enter the formula here, and click "Format."

=$B6""
Create a new rule

Set the formatting of the font.

Set the formatting of the font

Sets the fill formatting.

Fill formatting settings

Continue to create the four rules one after the other, starting from the top.

Order of creationMathematical formulasFormat
1=$C6="Earth"Blue fill
2=$K6="Company"Green fill
3=OR($K6="Happy"), C6="Day")Red fill
4=$B6""Border (outer frame)

The fourth rule of the border is to draw a border only on the rows containing dates.
Months with fewer days like February are designed to make the borders disappear.

Be careful with the order of the rules

Conditional formatting takes precedence over the rules above. Adjust the order of the images to ensure they remain in the same sequence.

Rules management screen
PairingRules
Top of the listBorder lines
SecondSundays and holidays (red)
ThirdCompany holidays (green)
Bottom mostSaturday (blue)

For example, January 2, 2027 is a Saturday, but it is also a holiday during the year-end and New Year holidays.
The company's vacation policy takes precedence over Saturday, so green is preferred.

The border rules do not have fill settings, so they can be compatible with other fill rules.

If you don't check the "Stop when conditions are met" option, you can draw the border regardless of the day of the week or holidays.

Hide the column of categories

Since column K is not necessary to show, right-click on it and set it to "hidden".

Hide column K

That's it. By changing the year, month, due date, and closing day, as well as the holidays and company holidays, everything—the date, the day of the week, and even the color—is automatically reflected.

important point

The schedule is written on a one-sheet per month basis.

This calendar changes the month when you switch it.Only the dateThe schedule I wrote in January will still remain in the same cell even if I switch to February.

When you write down your plans, use a sheet of paper.Copy the 12-month versionWrite it on a sheet of paper once a month.

Even if you copy the sheet, the formulas and colors will still be reflected properly, so when the year changes,Copy new copies of the entire bookPlease save it.

When opened on another computer, a yellow band appears.

If you open this file on another computer, it will appear as shown above."Security alert: External data connection is disabled."Sometimes a yellow band appears.

This is to check if it is possible to import the holidays from the internet,"Activate content"Please press the button.

Activating the content

In Mac Excel, "From the Web" is not available

There are several ways to import public holidays from the web:Excel for Windows is the prerequisite.However, there is no "from the web" feature in the Mac version of Excel.

For Mac computers, please download the CSV file of the holidays from the Cabinet Office page and import it into Excel. If you download it once a year, the holidays will be displayed.

If you want it to be read automatically, please do the following:"When creating using Google Sheets"You can use the method of

When created in Google Sheets

You can also automatically import holidays into Google Sheets. There are two ways to do this:

Method 1: Load it using the IMPORTDATA function (easy)

In the A1 cell of the "Public Holidays" sheet, insert the following formula.

=IMPORTDATA https://holidays-jp.github.io/api/v1/date.csv("")

The holidays for last year, this year, and next year are listed in column A with the dates, and in column B with the names. When you first load them, please press "Allow access."

The A column is initially displayed as numbers, so select A and then choose "Display Format" → "Numbers" → "Date."

However, this data is not managed by the country but by the individual. It may not always be available for use.

*When you import the CSV from the Cabinet Office using the IMPORTDATA function, the names of holidays are transliterated incorrectly. This is the same reason that Excel formats the characters in the same way.

Method 2: Read the Cabinet Office list using Apps Script (certainly)

Open "Extensions" → "Apps Script", then paste and save the following code.

// 内閣府の「国民の祝日」の一覧を読み込む(祝日シートで =SHUKUJITSU() と入れる)
function SHUKUJITSU() {
  const url = 'https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv';
  const csv = UrlFetchApp.fetch(url).getContentText('Shift_JIS');
  const rows = Utilities.parseCsv(csv);
  return rows.slice(1).map(function (r) {
    return [new Date(r[0]), r[1]];
  });
}

On A1 in the "Public Holidays" sheet =SHUKUJITSU() If you enter it, the list from the Cabinet Office will be included without any name being displayed. When the permission request screen appears, select your account and grant permission.

If you want to use it in your company's calendar, we recommend using Method 2, which imports it from the Cabinet Office.

Different from Excel

The dates, days of the week, and holidays can be entered in the spreadsheet almost the same way. However, the following points are different from Excel:

ExcelIn the spreadsheet
syukujitsu[National holidays and days off names] Specifying a table like thisPublic holiday! $B:$B, ,Public holiday! $A:$A Replace with a column designation like
Draw a border with conditional formattingConditional formatting doesn't allow you to draw borders. You have to draw the borders by hand.
By day of the week TEXT(B6,"aaa")If the day of the week doesn't display correctly,"aaa" を "ddd" Change it to

Summary

Year-and-month-change perpetual calendars can be made in three simple steps.

StepsTo do somethingWhat I used
1Automatically inserts date and weekday from year, month, and closing dateDATE function, TEXT function, data input rules
2Automatically loads the list of holidays and displays the names of the holidays.From the web (Power Query), the INDEX function, the MATCH function
3Automatically fills in for company holidays and non-working daysCOUNTIF function, conditional formatting

Once you create it, you won't need to change the date for the holiday or update the date to match the end of the month. Try using a perpetual calendar for your monthly or annual calendars.

Downloading the completed file (template)

The perpetual calendar created in this article can be downloaded from the link below.

By choosing the year, month, and closing date, it is ready to use immediately.
When using it, please do the following two things:

  1. When you open it, a yellow band will appear on the top,"Enable editing"Press the button and keep pressing it to get out."Activate content"Press "OK." This will load the holiday dates.
  2. Change the "Company Holidays" sheet to reflect your company's holidays.

Comment

en_USEnglish
Copied title and URL