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.
Back to the interactive calendar
Coming back to our topic at hand – interactive calendar, what do we mean by this?
Well, something like below:
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:
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:
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.
- 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.
9. Clean up and formatting
Clean up your worksheets and format the calendar so that it looks gorgeous. And you are done!
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:
- Employee vacation tracker & dashboard
- Creating perpetual calendar & event tracker in Excel
- Interactive pivot table calendar & chart in Excel
- Creating an interactive picture calendar
- Employee shift calendar template
- Annual goals tracker
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.