If you want to ensure that users enter dates correctly, the Excel Calendar Control can make things easier for both you and the users of the spreadsheet. With this hack, you can add the Calendar Control to any Excel workbook.
Unless a date is entered correctly, Excel won't recognize it as valid. This sometimes means you cannot perform calculations with figures that look like dates but aren't. It also means any charts or PivotTables based on these dates will not be valid. Although the use of Excel's very versatile validation feature (described in Chapter 2) can help with this, it is far from bulletproof.
With this hack, you
can add the Calendar Control to any Excel workbook. To start, open
the workbook for the calendar. It is a good idea to use your
Personal.xls file for this, in which case you
should first select Window
Next, select Tools
Right-click the Control toolbox and select Additional Controls. Scroll through the list until you see the Calendar Control 10.0 checkbox (the number will differ depending on the version of Excel you are using). Check the checkbox and click OK. Click the calendar that is now part of the toolbox and then click the UserForm you inserted earlier.
Using the size handles on both the UserForm and the Calendar Control, size the UserForm and Calendar Control to a reasonable size, as shown in Figure 7-6.
Make sure the UserForm is selected (as
shown in Figure 7-6) and then select View
Private Sub Calendar1_Click( ) ActiveCell = Calendar1.Value End Sub Private Sub UserForm_Activate( ) Me.Calendar1.Value = Date End Sub
Select Insert
Sub ShowIt( ) UserForm1.Show End Sub
Close the window to return to Excel.
Select Tools