Drop-Down Box with a Calendar

TJ

New Member
Joined
Aug 1, 2002
Messages
3
Is there a way to set up a designated cell in a spreadsheet with a drop-down box that will have a calendar, so that when you click on a date in the calendar it puts that date in the cell?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
i love this little calendar. So do many other people i work with.

i'd like to 2nd this question.

** Is there any way to make it reflect today's date?? *** :pray:

Would love some help on this. A simple point in the right direction would do.

Regards from Tokyo
 
Upvote 0
i love this little calendar. So do many other people i work with.

i'd like to 2nd this question.

** Is there any way to make it reflect today's date?? *** :pray:

Would love some help on this. A simple point in the right direction would do.

Regards from Tokyo

I have been looking at a number of calendar control threads and have come up with the following code which is MOSTLY doing exactly what I want:

Code:
Private Sub Calendar1_DblClick()
    ActiveCell.NumberFormat = "mm/dd/yyyy"
    ActiveCell = Calendar1
    Calendar1.Visible = False
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("C3:C5"), Target) Is Nothing Then
            Calendar1.Left = Target.Left + (Target.Width * 1.1)
            Calendar1.Top = Target.Top
        Calendar1.Visible = True
        Calendar1.Value = Date ' set calendar to today's date
    ElseIf Calendar1.Visible Then Calendar1.Visible = False
    End If
End Sub

Hope it helps!

the only think I can't get to work is I only want the calendar to appear in cells C3 and C5, but not C4. Any idea how to edit the range appropriately?
 
Upvote 0
Hmmm. i don't know how to skip C4 in the above code.
i used the code you provided and i get an error:

Runtime Error'424': object required

----i have the following in my sheet. Maybe there's a conflict with the first one??? ----

Any ideas to get it to work?


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If IsDate(Target) Or Target.Value = "mm/dd/yy" Then GetDate
End Sub

Private Sub Calendar1_DblClick()
ActiveCell.NumberFormat = "mm/dd/yy"
ActiveCell = Calendar1
Calendar1.Visible = False
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("C3:C5"), Target) Is Nothing Then
Calendar1.Left = Target.Left + (Target.Width * 1.1)
Calendar1.Top = Target.Top
Calendar1.Visible = True
Calendar1.Value = Date ' set calendar to today's date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
End Sub
 
Upvote 0
Hmmm. i don't know how to skip C4 in the above code.
i used the code you provided and i get an error:

Runtime Error'424': object required

----i have the following in my sheet. Maybe there's a conflict with the first one??? ----

Any ideas to get it to work?

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
 If IsDate(Target) Or Target.Value = "mm/dd/yy" Then GetDate
End Sub

Private Sub Calendar1_DblClick()
    ActiveCell.NumberFormat = "mm/dd/yy"
    ActiveCell = Calendar1
    Calendar1.Visible = False
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Application.Intersect(Range("C3:C5"), Target) Is Nothing Then
            Calendar1.Left = Target.Left + (Target.Width * 1.1)
            Calendar1.Top = Target.Top
        Calendar1.Visible = True
        Calendar1.Value = Date ' set calendar to today's date
    ElseIf Calendar1.Visible Then Calendar1.Visible = False
    End If
End Sub

I'm not really sure what might be causing your error. To get it to work, I had to place the code on the sheet object as opposed to a module. Also you need to add the calendar object to the sheet you want to use the calendar on: Insert/Object/Calendar Control 11.0

Sorry I can't help any more than that.[/code]
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,094
Members
449,095
Latest member
gwguy

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