Microsoft Office Tutorials and References
In Depth Information
Providing a Calendar to Choose Dates for Input
Figure 21 –Calendar Form
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Sub DisplayCalendar(Optional ByVal Target As Range)¶
'Variable declaration¶
'calendar form¶
Dim fmC As fmCalendar¶
Dim Cll As Range¶
'Was a range received?¶
If Target Is Nothing Then¶
'Use the active cell¶
On Error GoTo err_h¶
Set Target = ActiveCell¶
End If¶
'Ask for one date for each cell¶
For Each Cll In Target.Cells¶
Set fmC = New fmCalendar¶
fmC.Display Cll¶
Select Case TypeName(fmC.GetChoice)¶
Case "Boolean"¶
'do nothing, user pressed "Cancel"¶
Case "Date"¶
'assign the new date to the cell¶
Application.EnableEvents = False¶
Cll.Value = fmC.GetChoice¶
Application.EnableEvents = True¶
Search JabSto ::

Custom Search