How to create interactive calendar to highlight events & appointments [Tutorial]

Posted on April 9th, 2013 in Charts and Graphs , Learn Excel , VBA Macros - 26 comments

One of the popular uses of Excel is to maintain a list of events, appointments or other calendar related stuff. While Excel shines easily when you want to log this data, it has no quick way to visualize this information. But we can use little creativity, conditional formatting, few formulas & 3 lines of VBA code to create a slick, interactive calendar in Excel. Today, lets understand how to do this.

But first, a reminder to join my Advanced Excel masterclass in USA

As you may know, I am running my first ever Advanced Excel & Dashboards Masterclass in USA this summer (May / June 2013). We will be doing 2 day interactive sessions on Excel, advanced Excel, interactive charts, pivot tables & dashboards in Chicago, New York, Washington (DC) & Columbus (OH). If you live near any of these cities and want to become awesome in Excel, please consider enrolling in my Masterclass.

Click here for details & to book your spot | Download Masterclass brochure

Back to the interactive calendar

Coming back to our topic at hand – interactive calendar, what do we mean by this?

Well, something like below:

Interactive Event Calendar in Excel - Demo

How to create an interactive calendar from a set of events

1. Collect all the event data in a table

Just enter event data in a table like below:

Interactive calendar - event data

2. Set up a calendar in a separate rate

If your events span several months, then you can use formulas to generate calendar.

In my case, all the events (Masterclass sessions) are in May & June 2013. So I just entered date of May 1st in a cell, dragged it sideways and then re-arranged the cells to make it look like a calendar. At this stage, the calendar should look like this:

set up a blank calendar first - Interactive calendar

3. Name the calendar range

This is simple. Select all the cells in calendar range and give a name to it. I called mine “calendar”.

4. Assign a cell for identifying which date is selected

Select a blank cell in your workbook, give it a name like “selectedCell”. We will use this to identify which date is selected by user.

5. Write Worksheet_selectionchange() event

This will help us identify when user selects a cell in “calendar” range. The below 3 line VBA should do. Please attach it to the sheet where your calendar is.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("calendar")) Is Nothing Then
       [selectedCell] = ActiveCell.Value
    End If
End Sub

Tutorial: Showing details when user selects a cell

6. Set up the formulas to show details when a valid date is selected

Lets say, each event has 4 details associated with it – title, date, venue & description.

Now, we need to show details of the event when user selects a date in the calendar. Since the selected date is in “selectedCell”, we can use VLOOKUP, IF, IFERROR formulas to do this:

  • Fetch event title in a cell if date selected has an event in it. Else keep it blank
    • =IFERROR(VLOOKUP(selectedCell, table_of_events, event_title_column, false),"")
  • Fetch rest of event details, but keep them blank if date has no events.

Lets say these 4 details are fetched to cells D1, D2, D3 & D4 cells.

7. In calendar sheet, add 4 text boxes and assign them to cells

Finally, in calendar sheet, add 4 text boxes. Assign them to D1, D2, D3 & D4 cells. Arrange and format them as you fancy.

Tip: to assign a cell to text box, just select the text box, go to formula bar and type =D1 press enter.

8. Set up conditional formatting to highlight selected dates

Finally, add a simple conditional formatting rule to highlight the selected dates in calendar. This is simple. Assuming calendar starts at cell A1,

  • Select the calendar range
  • Go to conditional formatting
  • Add new rule
  • Select rule type as “Use a formula to determine which cells to highlight”
  • type the rule as =A1=selectedCell
  • Set up formatting

PS: in my data above, I have used different formula as we need to highlight 2 dates of a Masterclass even when 1 is selected.

Tip: Introduction to conditional formatting.

9. Clean up and formatting

Clean up your worksheets and format the calendar so that it looks gorgeous. And you are done!

Finalized Interactive calendar

 

Download Interactive Calendar Example file

Click here to download interactive calendar example file and play with it to understand this better.

Examine the formulas in “Calcs” sheet & VBA code so that you can see how this is weaved.

Work with calendar data often, then you are in luck

If you use calendar data often and are looking for some inspiration, ideas & examples on how to represent it, then check out below examples:

Do you like the interactive calendar?

I often use interactive calendars in my dashboards & client projects. Since calendars are very natural way to understand events, they work really well.

What about you? Do you use calendars often? How do you like the above technique? Please share your thoughts & ideas using comments.

PS: And if you are waiting to become awesome in Excel, then wait no more. Book your spot in my upcoming Masterclass. Click here.

 

Your email address is safe with us. Our policies

Written by Chandoo
Tags: , , , , , , , , , , , , , ,
Home: Chandoo.org Main Page
? Doubt: Ask an Excel Question

26 Responses to “How to create interactive calendar to highlight events & appointments [Tutorial]”

  1. Fezile says:

    Awesome
    How do you deal with more than 1 calendar entry on a specific day?

  2. dz says:

    Calcs:G12 presents the dates better as: =IFERROR(TEXT(MIN(I3:I4),”d,”)&TEXT(MAX(I3:I4),”d mmm”),””)

  3. Love the aesthetics. Is Segoe UI the best font or what?

  4. indzara says:

    Chandoo,
    This is a very good implementation and use case of interactive calendars. In my templates, so far, I have used dynamic calendars but not interactive ones. One is a Calendar template for customizable printable calendars and the other is a Task Manager template where I used a mini calendar. 
    Is there a way to identify the selected cell without the VBA code?
    Thanks,

  5. CC says:

    Love this one! This may have already been shown somewhere, but how could I add to this by having the calendar highlight dates that had some event connected with them? So, in the little mini-calendars, if there was some event on May 1, it might have a light yellow background, or be bold. I’d click on the date to see the details of the event, but it would be nice to see at a glance which dates were ‘filled’.
    Thanks for a GREAT site!
     
    CC

  6. CC says:

    That worked perfectly, thanks so much!

  7. JohnC_UK says:

    Chandoo you really do present some very clever techniques and I’m learning a lot from your site.
    A little bugette/feature in this sample though…
    1. Change the dates for the New York events to 1st / 2nd June in the hidden calcs sheet.
    2. Click the green June 2013 calendar caption.
    June 1st / 2nd are highlit (as the green caption also has the date 1/6/13.)
    There are two ways to avoid this.
    1. Change the range for the calendar named range to two regions of the calendar days. (=calendar!$B$7:$H$11,calendar!$B$14:$H$18)
    2. Make the calendar days unlocked and de-select the option “Select locked cells” when you protect the calendar work sheet.
    I prefer option 1 as it is cleaner and defines exactly which cells you are interested in tracking.
    i know you know this but I just thought I’d point it out for people who read your site. (That’s how I’m learning Excel!!! – by others posting examples based on their own experience.)

  8. JohnC_UK says:

    Chandoo
    To clarify my previous post.
    It was not a nit-picking, point scoring post to try and point out a “bug”.
    It’s just that I have 24 years of computer programming experience which makes me instinctively test worste case scenarios. That’s what led me to this observation.
    However, as far as Excel goes I’m nowhere near competent and I do appreciate that you and lots of the posters on your site make my Excel skills look like a beginner!!!
    My advice is to always try and think of extreme examples and see if your spreadsheet copes with it.

  9. Anil J says:

    Chandoo,
    Awesome. But I found a small problem, when I selected 31, the Details block showing the dates as “31-30 May”. Please correct it.

  10. Joe says:

    Perfect thank you!

  11. Herman says:

    Bravo Chandoo!!! After reading this article and another one (perpetual calendar) from you, I think that it would be great if you could combine both ideas to make an interactive perpetual calendar. Do you think it is possible!?

  12. Shirley Poehlman says:

    I have to say that for the past couple of hours i have been hooked by the amazing posts on this site. Keep up the great work.

  13. Ranjit says:

    Hi Chandoo

    VBA was really good,

    Thank you,

  14. Somendra Misra says:

    the VBA code is working well on Office 2010, but is not working on Office 2011 for MAC OS X. Any idea?

  15. Danilo says:

    When I try save the spreadsheet show this message: “The following features cannot saved in macro-free workbooks.”

  16. WimpieO says:

    I am working in excel 2010and would love to download your example file is i can not seem to get steps 6 & 7 figured, any help with this or a more in depth explanation will be greatly appreciated

  17. […] Sounds like a very interesting project. Maybe check out this tutorial to get your creative juices flowing Chandoo.org […]

  18. Ceetoo says:

    Hello Chandoo…
    can I get a video for this pls? or a more detailed instructions on what to do. I am new to excel but I have a task to do this.

  19. Josh says:

    Any chance something like this could be worked into google’s spreadsheet and calendar programs? I use google spreadsheets for work so that other employees can view and Id love to be able to transfer that info into google calendar so myself and other employees can view past info. Thanks

  20. Ronnie Fisher says:

    Can someone assist me in creating one of these interactive calendars for 2015. I need a very comprehensive calender. My calender need to be from January 1, 2015 to December 31, 2015. I can have up to 200 events on one day. My event data table is big.

    Thank You in advance.

    Ronnie

Leave a Reply