Welcome to MSDN Blogs Sign in | Join | Help

Sam Radakovitz on date pickers

Today’s author: Sam Radakovitz, a program manager on the Excel team that enjoys creating VBA applications in Excel.

Back in early 2005, Excel 2007 was under development, the Backstreet Boys released a new album, and I took a weekend out to create a date picker add-in for Excel.  The add-in was fun to write, not super duper fancy code, but it got the job done and helped me learn about the various Excel events and Excel’s add-in model.  I pushed it up on the web, got some feedback and made a couple of iterations on it, and by the end of the year I had wrapped it up and moved on to other things. 

Recently this add-in got demo’d at a Microsoft event and it made it back on my radar.  I decided to write a blog post about the add-in since some folks might find it useful … or at least spark some conversation about date pickers in Excel.  If you want to try the add-in for yourself, you can download it and the sample file I’m going to use for this blog post here:

After downloading the add-in, you can stick it in your XLSTART folder (mine is at C:\Program Files\Microsoft Office\OFFICE12\XLSTART) and restart Excel for it to load. 

The sample file contains a small list of projects for a department store.  I’ve made the list small and removed some columns of information to keep things simple.  With the date picker add-in installed, choosing a date in a cell will put an icon next to the date:


This is the entry point we will use to view the date picker, there are other entries points but I’ll get into them a bit later in the post.  Clicking on the date picker icon will display the calendar:


The calendar fades in and defaults to the date that is in the selected cell.  The green highlighted day represents where your mouse is.  When you move the mouse to a different day, you’ll notice a few things change:


The green highlight moves with the mouse.  The blue highlighted date, in this case January 1st, represents the selected cell’s value.  As the mouse moves, the status text at the bottom tells you the date difference from the selected cell’s value.  In this case we’re hovering over January 15th, so the status text is saying we’re going to move the date forward 14 days if we click on it.  You can change how the status text displays the difference by clicking on the text:


Now instead of 14 days it says 2 weeks.  Clicking on it will cycle through a few different groupings.  To change the month displayed or the year, you can pick from the combo box at the top of the calendar or change the months by clicking on the left or right edge of the calendar:


Clicking the options button in the upper right of the calendar will fly out the options pane.  Here you can specify the entry points you want visible and turn on and off the fading of the date picker:


Choosing the “In Cell Icon Settings…” button will display a popup of the different icons for the date picker control and give you additional options on where you want the icon position in the cell:


The cell icon will display when a date is selected, but there are other times it will display too.  Below is a quick list of the entry points to the date picker:


The last thing I want to mention about the date picker is the warning text.  If you have a formula (or other various things) populating the cell, picking a date will overwrite it.  To help inform folks that the date picker is going to blow away the formula for the cell it will display some warning text on it:


And that’s about everything this date picker can do in a nut shell.  There are some enhancements I’d like to make, not sure if I’ll get to them though:

  • Update it for Excel 2007 & create nice ribbon buttons
  • Support for setting time, like 2:30pm
  • If a cell has a formula of =A1, and A1 is just a date, then I’d like to set A1 instead of blowing away the formula that refers to A1
  • More ‘semi-smart’ detection for when to show the icon in the cell based on the data or objects around it
  • Multiple visible months (previous and next to the left and right of the current month)
  • Ability to limit the days available to choose from based on a cell reference
  • Make a managed code version of it, right now its VBA and User Forms
  • International support

If you have any ideas or comments, or a date picker you love to use, please post them here!

Published Wednesday, August 01, 2007 2:13 PM by David Gainer

Comments

# re: Sam Radakovitz on date pickers

Wednesday, August 01, 2007 7:49 PM by Joe Curious

Are you going to include this in the next Excel version?

# re: Sam Radakovitz on date pickers

Wednesday, August 01, 2007 8:35 PM by Sam Rad

Joe Curious - I don't think we would include this exact add-in if we did something ... and if we do something still remains to be seen, not sure if we know the demand for a feature like this (David Gainer would know better than I).

# re: Sam Radakovitz on date pickers

Thursday, August 02, 2007 12:38 AM by d.volans

your date picker is very useful!

# re: Sam Radakovitz on date pickers

Thursday, August 02, 2007 12:50 AM by Charles Miles

Your date picker looks interesting so I was really interested in reading and learning from your code - but it seems like the vba project is password protected? Any chance that will change?

Thanks,

Charles

charles@cmiles.info

# re: Sam Radakovitz on date pickers

Thursday, August 02, 2007 6:31 AM by arun.philip

I like the warning text idea. It also shows you've fully thought through the various usage scenarios.

My only gripe is a minor one - the look and feel doesn't gel in with the rest of the Office 2007/Ribbon look.

# re: Sam Radakovitz on date pickers

Thursday, August 02, 2007 3:53 PM by Sam Rad

d.volans - thanks!

arun.philip - thanks!  I haven't touched the UI or colors since 2005, so I haven't really updated it to match with all the new fancy Office 2007 stuff.

Charles Miles - Possibly ... I'll have to dig up the source, I haven't touched it in a while, so I think its on an external HD somewhere at home.  On creation, I type in a long random password and obfuscate the code.  Maybe the source could be another blog entry.

# re: Sam Radakovitz on date pickers

Thursday, August 02, 2007 7:07 PM by Colin Banfield

Sam, thanks for this useful date picker.  For the next version of Excel, I'd like to see a date picker incorporated into Data Validation.  A date picker would be a natural pop-up for an input cell(s) with a validation criterion of "Date."

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 12:57 AM by date picker user

There is also a nice calender utility that navigates with keyboards too  from below site of Shah.

http://in.geocities.com/shahshaileshs/

Thanks,

date picker user

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 5:30 AM by chris h

date picker is great! just a minor remark:

In the date picker, if one selects the month drop down, the currently selected month (i.e. august) is highlighted. But if one changes one's mind at that point, or if you have clicked on the month drop down by error, you cant exit the drop down while keeping august selected. (datepicker apparently waits for a new input)

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 6:14 AM by Neil

I'd echo the previous comments that this looks impressive, and add that I've seen requests for datepickers so many times on Excel forums, that this should either be included in future versions, or made widely available.

Seeing the source code would also be a big help, as I've recently built something similar so that my users wouldn't have to enter dates manually into userforms.

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 7:44 AM by AdamV

Two comments:

This is great!

however, a date changed by the date picker does not apear in the undo list as far as I can see, which makes it something I would not give to some users. Changing the wrong date in (say) a forecasting tool could have huge consequences, being able to use "undo" is pretty vital. If it's too hard to do this through the built in feature (which I would find odd) then an internal system to track these changes and provide a choice in the pop-up window of "revert to previous value" would be perfect.

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 9:35 AM by Rich Williams

Great tool - I like its ability to show "Back" and "Forward" number of days away from the current date.

This would be a handy tool for Outlook Appointments!

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 1:22 PM by Jan Karel Pieterse

Nifty tool.

One point of criticism: I'm not fond of advising people to put the file in XLSTART.

I would have built a real addin (.xla) as opposed to a hidden xls so you can enable it when you need it in Tools, Addins.

# re: Sam Radakovitz on date pickers

Friday, August 03, 2007 9:07 PM by Charles Miles

I hope you do show the source at some point - always educational to look at the code for useful interesting projects like yours.

I am curious why you "type in a long random password and obfuscate the code" on creation of the project - do you do that on every project? Just curious!

Thanks,

Charles

charles@cmiles.info

# re: Sam Radakovitz on date pickers

Saturday, August 04, 2007 12:45 PM by Sam Rad

Colin Banfield - nice, I would imagine it in data validation as well.

date picker user - thanks for the link!

chris h - thanks!  I'll have to fix that if I ever get to editing it again.

Neil - thanks!

AdamV - thanks!  yeah I should add to the undo stack, I'm not sure how to off the top of my head, but I remember seeing example VBA code somewhere that did it.

Rich Williams - I'll mention it to the outlook team!

Jan Karel Pieterse - thanks!  it is an XLA, so if you want to put it in a different directory and load it through the add-in manager it should work.  XLSTART is just how I was doing it.  Though for some reason when i goto download the XLA IE says its an XLS ... ?

Charles Miles - only some projects, I don't think there was a special reason for it back then (at least I can't remember one).

# re: Sam Radakovitz on date pickers

Saturday, August 04, 2007 3:27 PM by dbowe

Hi,

It's a really really well designed tool. I think the only problem is the way it's applied. I strongly agree with other reader that you should be able to apply it as a validation control. It's uses become limited when you need a date or the text 'date' in a sell above the desired cell. Is there any plan to extend the functionality to implement this. Or can you make your code open for extension by other people??

Again, brilliant control. I really like the UI. thanks

# re: Sam Radakovitz on date pickers

Monday, August 06, 2007 5:30 AM by Hanan

Hi,

It really a great tool.

I am using right to left user interface (Hebrew UI)and if I click on the toolbar button, the calender is cut on the right side of the screen so I can't pick the year from the combo box or to click of the option button.

thanks,

Hanan

# re: Sam Radakovitz on date pickers

Monday, August 06, 2007 9:55 AM by Jan Karel Pieterse

Sam: I have the same experience, clicking the link somehow convinces IE that it has an xls file to save, not an xla. On my site that kind of trouble does not exist because I tend to create zip files for download.

# re: Sam Radakovitz on date pickers

Monday, August 06, 2007 11:36 AM by Johan De Schutter

Hello,

I have a few questions.

1)How did you put the icon next to the date? Did you use vba? Is this icon a shape? Could you give a code example?

2)How did you create the date picker? Is it also a shape, or is it maybe a modified userform? Or maybe some activeX-component? Could you give a code example?

3)Could you post the source code (or parts of the source code). The icon and the date picker are very nice looking and useful features. It is really an extra to the user interface (data validation, userforms) of Excel.

thanks,

Johan zendjohan AT hotmail DOT com

# re: Sam Radakovitz on date pickers

Monday, August 06, 2007 1:44 PM by Sam Rad

dbowe - Yeah more detection on when to show the icon in the grid and integration with data validation stuff would be sweet.   Just to note: in the scenario “above the cell”, you can still right click the cell and put the date in :-)  I’ll work on sharing out the code.

Hanan - Thanks!  I didn't test international scenarios at all on the control, looks like a bug :)

Jan Karel Pieterse - Strange, I'm wondering if the XLA -> XLS thing is an IE issue or a website issue.  Either way putting it in a zip is probably the way to go.

Johan De Schutter -

1) What is the icon - the icon is a shape with a picture in it.  On load, if I remember correctly, I dump out an image to the temp directory that is the picture of the calendar, then use it on the shape.

2) What is the date picker - It’s a VBA user form with labels, combo boxes, and images.  If I remember correctly (again), I use some API’s to hide the title bar and fade in and out the user form.  Each day is a label and the background of the form is an image.

3)Share the code – I’ll get on it and take a pass through my backup hard drives, sounds like multiple folks would want to take a peek at it … or even better: enhance it.  I’ll work to post it here or in another blog post.

# re: Sam Radakovitz on date pickers

Tuesday, August 07, 2007 4:45 AM by Andy Cotgreave

That's a great add-in - i'd like to add to the call to see the source code: there's some really nice little touches in here that i could learn plenty from.

Thanks for posting the XLA though: it'll be enhancing my Excel experience right away!

New Comments to this post are disabled
 
Page view tracker