Drop down calendar function

P

Piers

I am creating a spreadsheet and would like to include a drop down menu with a
calendar format to avoid typing the date longhand. Can anyone suggest how
this is done ?
 
G

Gav123

Hi Piers,

You can do this with a macro..

Right click on the icon nex to File in the menu bar at the top of the
screen, select the sheet where you want the calender from the options on the
left.

Paste this into there...

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "dd/mm/yyyy"
ActiveCell.Select
If Calendar1.Value Then
Calendar1.Visible = False
End If

End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A1:A5"), Target) Is Nothing Then
Calendar1.Left = Target.Left + Target.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If


End Sub


Change the range ("A1:A5") at this line to fit your requirements...

If Not Application.Intersect(Range("A1:A5"), Target) Is Nothing Then

Hope this helps,

Gav.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top