So you want to create a drop down calendar in Excel? Apart from sending alerts to Outlook from Excel (working on that article as well) this has been the most requested how-to as of late. For example:
Reader Tim Asks:
How do I insert a calendar as a way for a user to click on the cell have the date box open and choose the date that should be in the cell? Also where do I send the beer?
Reader Wayne Asked:
I am sure that I saw a pull down menu in a worksheet cell. I want to have a cell formated so that I can have a pull down menu of a calendar in which to choose the date.
This seems like it would be so easy yet when you look around on-line the answers are all full of VBA scripts and custom code.
I assume you just want someone using the spreadsheet to be able to select a cell, have a calendar drop down and then populate the field with whatever date the person chooses. Yes it can be done. Yes it is fairly involved. And yes, I have a workaround.
Would you like the easiest, cheesiest, sleaziest way to do this? Well then watch this:
- Select the Pearl or "Office Button" in Excel. The Pearl is the ball in the top left corner that gives you the option to Print, Save, etc.
- With the Pearl menu open select Excel Options from the very bottom on the right.
- Another menu will open – Select Popular
- Check the box for "Show Developer Tab in the Ribbon"
Now you have the developer tab with all the controls for forms, xml, code, etc.
Go to the developer tab and select Insert, followed by the little Pink Floyd-esque More Controlsicon.
Scroll through the list of controls and look what's available. There are all sorts of funky add-ins you can use in your spreadsheets! We are looking for the Calendar Control 12.0 and click OK
Your mouse will turn in to a cross hair – click and hold, draw a rectangle, release. You now have a date box!
You will also see code in the top akin to "=EMBED("MSComCtl2.DTPicker.2″,"")"
You will also notice that you are in Design Mode because that icon is highlighted. This allows you to play with the settings for the date box you just created.
Deselect Design Mode and you have a date control! Select the drop down and a calendar appears! Holy Cow that's super cool awesome but guess what! It doesn't do anything!
You can click it and change the date as much as you want but nothing else is changing in your spreadsheet!
Here is where the genius of my non-code writing laziness pays off. Ready?
What cell do you want the date to change in? Let's say C5
- Ok, In B5 type SELECT DATE:
- In D5 enter the formula =C5
- Still got that calendar control visible like in the image above?
- Let's go back to Design Mode by clicking it. Move the calendar control box up around the C3 area just to move it out of the way.
- Right Click in the calendar control and select Properties.
- A properties menu will open up
- Look for the field Linked Cell and enter C5 (that's where we want the date change to happen)
- You might get an error message – ignore it!
- Close the Properties menu
- Deselect Design Mode
Here's where it all comes together. .
- Select the Date Drop down and change the date
- You will see Cell C5 change to that date
- You will see cell D5 (which =C5) change as well. The D5 was just to ensure that C5 was actually showing a date.
- Repeat step 1-3 until you are as giddy as a little girl.
Last Question: How do I use this?
Well you can create as many of these drop downs as you like. You can tell each one what cell to update (Linked Cell) and you can move the Date Control right over the top of the field it is updating! Think about that – Move the date picker right over the top of the cell it is linked to. Only you know the truth! There is no advanced code, you're just hiding the data in C5 under the Date control that is updating or controlling C5! Then do any date calculations you need to do using C5 as the reference!
I told you it was sleazy, cheesy and easy!
I'll make it even easier – here's the spreadsheet I used to write this tutorial and take screen shots
And Tim, You any any other reader can always send the beer to me by clicking beer mug at the top of the page.
Tidak ada komentar:
Posting Komentar