How to insert a date selector in Excel
In the Development toolbar, select Insert-Other controls, and open other control selection boxes.
Select the Calendar control8.0 in the selection box to determine.
Draw the calendar in the right place and adjust the height and width appropriately. This time the calendar control is also relatively original, do not click on the date automatically hide the calendar and fill in the cell date, then you need to add your own code.
Double-click the calendar in design mode.
Click Design mode to open the Code editor when the color of the chart becomes darker and is the design mode.
Enter the code below at the cursor:
ActiveCell = Calendar1.value Me.Calendar1.Visible = FalseEnd Sub
Private Sub Worksheet_selectionchange (ByVal Target as Range)
If target.column = 1 Or target.column = 2 Then
' Here's 1 and 2 for you to display the column ordinal of the calendar
Me.Calendar1.Left = Target.left Me.Calendar1.Top = target.to If target.value <> "" Then Me.Calendar1.Value = Target. Value Else Me.Calendar1.Value = Now (end I Me.Calendar1.Visible = Truelse Me.Calendar1.Visible = FalseEnd If
Close the Code Editor to save Excel as a macro-enabled workbook.
To open the workbook again, click the first column or the second column to eject the calendar selector, select the date, insert the date in the cell, and the calendar selector disappears. Note that this is only possible in the non-edit mode.
Excel has another simple calendar selector, Microsoft Date and Time picker control (SP6), in addition to the calendar controls.
When you insert the control, you can click on the pop-up date selection interface in non-design mode. As follows: