Thread: Calender Help
View Single Post
  #4   Report Post  
swatsp0p
 
Posts: n/a
Default Calender Help


Alexanderj Wrote:
Hi

Please can someone help me, i am designing an Excel worksheet to hold
dates and calculate days, i have two fields one for "start date" and
one for "end date" what i would like to know is, is it possible when a
cell is clicked under "start Date" a little calender pops up a date is
chosen and is displayed in the selected cell. If it is possible please
can someone help me.

Many thanks


Try this:Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "dd-mmm" 'adjust this date format to meet
your needs
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("A1"), 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
Else: Calendar1.Visible = False
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Adjust the 'Range("A1") line to meet your needs.

NOTE: use of an Event Code will probably make other functions
inoperable (e.g. cut/copy/paste, Undo, etc.). This is a trade off you
need to accept if you really want this tool.

Good Luck


--
swatsp0p


------------------------------------------------------------------------
swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
View this thread: http://www.excelforum.com/showthread...hreadid=483870