Set rngDP = Union(Range("A1"), Range("B5"), Range("C2"))
and that can easily be changed to include any number of contiguous and/or non-contiguous cells.Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim ws As Worksheet
'Dim rngDP As Range
Set ws = ActiveSheet
On Error Resume Next
grngCurrent.Value = DTPicker1.Value
' Set the range where you want the date picker to appear
'Set rngDP = Union(Range("A1"), Range("B5"), Range("C2"))
'If Intersect(ActiveCell, Range(rngDP.Address)) Is Nothing Then
If Intersect(ActiveCell, Range("D13:D34")) Is Nothing Then
DTPicker1.Visible = False
Exit Sub
End If
Set grngCurrent = ActiveCell
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.CutCopyMode Then
'allows copying and pasting on the worksheet
GoTo errHandler
End If
With DTPicker1
.Font.Size = 8
.Visible = True
.Left = Target.Left + 1
.Top = Target.Top + 1
If Target.Width >= 65 Then
.Width = Target.Width - 1
Else
.Width = 65
End If
.Height = Target.Height - 1
.Text = Target.Value
.Activate
End With
errHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub