Help with Date & Time Picker Control showing next to active cells

ian_isnt

New Member
Joined
Jan 14, 2015
Messages
1
Hi all, hoping someone can help me with this problem please.

I'll start by saying that I am not familiar with VBA and have mostly cobbled this code together by reading various posts on this forum so apologies if the code is total rubbish!

I have added a Date Picker Control to my sheet and want it to appear next to the selected cell but only in columns 1, 4 and 6

I have managed to get it to do this but there are some side effects....!

After I have selected a cell for the first time subsequent selections cause the date picker to appear next to the new selected cell but only as a drawing object. The active picker remains next to the original cell that was selected. i.e. I now have 2 pickers displayed but only the original actually does anything.

This original stays in the same place no matter which subsequent cell I select.

Both copies do disappear if I select a cell that isn't in columns 1, 4 or 6 or if I scroll the mouse wheel but not if I use the arrow keys to select new cells or click to select a new cell.

Hopefully that makes some sense, code pasted below if anyone can help clean it up and get it working that would be great. I have named the Calendar Control Calendar1 in the properties screen but all other values have been left at default. I am using Excel 2010 on a 32 bit OS if that makes any difference.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Calendar1.Visible Then Calendar1.Visible = False
Select Case Target.Column
Case 1, 4, 6
If Target.Count > 1 Then Exit Sub
Calendar1.Left = Target.Left + Target.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
Calendar1.Value = Date
Case Else: Exit Sub
End Select
End Sub
Private Sub Calendar1_Click()
ActiveCell = Calendar1.Value
Calendar1.Visible = False
ActiveCell.Select
End Sub

Thanks in advance, Ian
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top