Excel 2010
When I select the target cell/s the calendar appears and I am able to make selection on calendar. However, after date is selected on calendar I have to click on the date in the control to force the date to transfer to cell and make date control (DTPicker) go away. Would like to have the date appear in target cell after date selection in control and calendar to exit afterward without having to select the date again. I originally used this code in Excel 2003 but calendar control is no longer available for usage in 2010. I am sure the code needs to be tweaked to make the transition to 2010.
Thanks!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range
Set rng = Intersect(Target, D010.Range("IncidentDes"))
If Not rng Is Nothing Then
Load frmTextEntry
frmTextEntry.Show
D010.Range("SC1").Select
Else
If Not Application.Intersect(Range("AZ69:AZ77,K6,K7,K81,AQ81"), Target) Is Nothing Then
DTPicker21.Left = Target.Left + Target.Width - DTPicker21.Width
DTPicker21.Top = Target.Top + Target.Height
DTPicker21.Visible = True
' select Today's date in the Calendar
DTPicker21.Value = Date
ElseIf DTPicker21.Visible Then
DTPicker21.Visible = False
End If
End If
End Sub
__________________________________________________________________
Private Sub DTPicker21_Click()
ActiveCell.Value = CDbl(DTPicker21.Value)
ActiveCell.Select
DTPicker21.Visible = False
End Sub
When I select the target cell/s the calendar appears and I am able to make selection on calendar. However, after date is selected on calendar I have to click on the date in the control to force the date to transfer to cell and make date control (DTPicker) go away. Would like to have the date appear in target cell after date selection in control and calendar to exit afterward without having to select the date again. I originally used this code in Excel 2003 but calendar control is no longer available for usage in 2010. I am sure the code needs to be tweaked to make the transition to 2010.
Thanks!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range
Set rng = Intersect(Target, D010.Range("IncidentDes"))
If Not rng Is Nothing Then
Load frmTextEntry
frmTextEntry.Show
D010.Range("SC1").Select
Else
If Not Application.Intersect(Range("AZ69:AZ77,K6,K7,K81,AQ81"), Target) Is Nothing Then
DTPicker21.Left = Target.Left + Target.Width - DTPicker21.Width
DTPicker21.Top = Target.Top + Target.Height
DTPicker21.Visible = True
' select Today's date in the Calendar
DTPicker21.Value = Date
ElseIf DTPicker21.Visible Then
DTPicker21.Visible = False
End If
End If
End Sub
__________________________________________________________________
Private Sub DTPicker21_Click()
ActiveCell.Value = CDbl(DTPicker21.Value)
ActiveCell.Select
DTPicker21.Visible = False
End Sub