Pick a date from a cell drop down calendar

P

Paul Dennis

I have put a calendar pop up in a cell after looking how on
http://www.rondebruin.nl/calendar.htm

It all works for me and most others, but some people are getting a vb error
not just on this cell but all cells. The error is Compile Error" "Can't find
project or library".

It has been sugested that the error is due to the Calendar control being a
part of Access ? Is this true ? If so is there a way around this as I can't
ask people to install Access?
 
R

Ron de Bruin

Hi Paul

Yes that is true
See the link I have on my site to the page with the useform example
you can download the control there if you want
 
P

Paul Dennis

I replaced the code but it didn't make any difference

from:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$I$30" Then 'Change this
Calendar1.Visible = True
Calendar1.Value = Date
Else
Calendar1.Visible = False
End If
End Sub

to:

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

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("I30"), Target) Is Nothing Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
' select Today's date in the Calendar
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
End Sub
 
Top