«

»

How to make automatic calendar in Excel

Creating a new calendar each month is a waste of time, but many people do as they think they need to rebuild it to get correct weekends and public holidays.

But in fact, with few formulas, 2 conditional formatting rules, 1 dropdown list and 5 lines of VBA code, you can create an automatic calendar.

You can download the file at the end of this article 😃

Step 1: Add a dropdown list

Let's start by writing the employees' name in column A

Do you have the developer tab in your Ribbon? No, so

  1. Go to the menu File>Options
  2. Then Customize the Ribbon
  3. Check the developer option in the right pane

Now, select Developer>Insert>Combo Box

Then left click and drag your mouse to create a drop-down objet in your worksheet like in this picture.

 

 

Create a list of months

Automatic_Calendar_4Now we need to create a list of month somewhere else in our worksheet (use the technique to fill series for that 😉)

In my case I have to create this list 32 columns away from my source data (maximum number of day per month + the column of the employees' name).

 

Now, connect the Combo Box with this list of month.

  1. Select your Combo Box object
  2. Right-click on it ⚠⚠⚠
  3. Select Format Control ...

 

 

 

The Format Control dialog will open.

  1. Select the Control tab (the last one)
  2. Select the range of month (in this example AH1:AH12
  3. In the Cell link, select A1 (explanation, just under)

What is the cell link?

The Cell link is the cell that will collect the value of the index of the element selected.

  • If you select May, the 5th element in the list, the value in A1 will be 5
  • And if you select September the value in A1 will be 9
  • ...

 

Why choose A1? It's tricky 😉 In fact, the drop-down object is above the cell A1. Like that, the end-user will not see the result of the cell linked.

The location of the Cell link is crucial for the rest of the explanation. It has in impact on the formula DATE and with the macro.

Step 2: Another Drop-down list for the year

On the same way,

  • Create a list of years in a column (it's just the value of the year, not a date)
  • Insert a new drop-down list
  • Link this new drop-down list to this range of year
  • Select A2 as a Cell Link

 

Step 3: Create the first date in function of the drop down

Here, we are going to re-used the contains of A1 (month selected) and A2 (year selected) and put them in the DATE function. If you are not familiar with the DATE function, have a look at this article.

So, let's create the first day in function of the value of the drop down object.

  • The year it's the value of the cell link A2 + 2016 (yes, the first year in the list is 2017, so the result in A2 will be 1 and not 2017)
  • The month is just the value of A1 (easy)
  • And the day is 1 (first day of the month)

In B6, the formula is

=DATE(A2+2016,A1,1)

Step 4: Extend the days

This step is very easy.

We just have to add 1 to the previous cell to increase your series of days.

  • In C6, write the following formula
  • Copy the formula till the cell AF6

=B6+1

Step 5: Change the date format

Now we are going to focus on the date format.

We already have the year and the month in the upper left corner, so we don't really need this information in our cells. What we need, it's just to display the days of our dates.

To do this, we can change the format of the date in the row 6 to display only the day. We want to display the short name of the day and also the figure.

  • Select all your dates (from B6 to AF6)
  • Open the Format Cells dialog box (Ctrl+1 or Home>Cell format>More Number format)
  • Select the Custom category
  • Enter ddd dd in the Type field.

Step 6: Change the orientation of the text

Now let's change the orientation of our date:

  • Select B6:AF6
  • Activate the menu Home
  • Orientation
  • Rotate Text Up

Then, adjust the size of the columns B:AF to get this presentation.

  • Select columns B:AF
  • Right click a the column header
  • Set the column width to 2.5

Step 7: Add color and borders

Now, add some color and borders to your calendar. Pretty nice 😍😍😍

Step 8: Add a dynamic title

Now, we are going to create a dynamic title with the first and last day of the month.

The formula for the first day of the month is

=DATE(A2+2016,A1,1)

The formula for the last day of the month is

=DATE(A2+2016,A1+1,1)-1

And to customize the result, we must include these 2 formulas in the TEXT function. The parameter of the TEXT function is the format of the date you want.

="Period from the "&TEXT(DATE(A2+2016,A1,1),"dd mmmm yyyy") &" to the "&TEXT(DATE(A2+2016,A1+1,1)-1,"dd mmmm yyyy")

And the result is:

Step 9: Highlight the weekends

Step 14: Conclusion

And THAT'S IT 😎😍👍

Now, each time you select a month in your drop-down list, your calendar will automatically change the color of the weekend, holidays (providing your list is up to date, of course) and also hide columns as necessary.

Permanent link to this article: https://www.excel-exercise.com/how-to-make-automatic-calendar-in-excel/


5 comments

Skip to comment form

  1. Lucie

    Hello Frédéric,

    thank you for great calendar. I’ve added here also combo box with years. Unfortunately years are read as serial numbers.
    E.g. my list of years starts from 2018, it got serial number 1, and is read as year 1901

    Could you give me a hint how to solve that?

    Thanks

  2. Dave

    Great Calendar and I have it working to high light weekends but have spent 3 days and can not get the stat holidays and macro to work is there a copy where all of this is built, I am not a technical IT type but I do try. Thanks

    1. Frédéric LE GUEN

      Hi Dave,
      I have added the file. It is included in the pay-per-view part

  3. shamik

    Hi,

    i really liked you design, can you share the template ?

    1. Frédéric LE GUEN

      It has been made from scratch and it’s not downloadable.

Leave a Reply

Your email address will not be published. Required fields are marked *