+ Reply to Thread
Results 1 to 2 of 2

excel calendar years

  1. #1
    whowatwerwyhow
    Guest

    excel calendar years

    Hi,

    I'm trying to use the calendar tool in Forms under the VBAProject so that
    the years dropdown list only displays the years 2005 and 2006 (instead of all
    years from 1900 thru to 2100). Is there a way to limit the years to only 2005
    and 2006?

    If not, is there a way to display an error message so that the user can be
    told to enter a date between 2005 and 2006 if they don't? I've got a
    validation check but this seems to have no effect when the date is entered
    using the pop-up calendar tool.

    Thanks in advance.

  2. #2
    Ron de Bruin
    Guest

    Re: excel calendar years

    Hi

    If you use it on a worksheet you can do this
    see also
    http://www.rondebruin.nl/calendar.htm

    Private Sub Calendar1_Click()
    If Year(Calendar1.Value) = 2005 Or Year(Calendar1.Value) = 2006 Then
    ActiveCell.Value = CDbl(Calendar1.Value)
    ActiveCell.NumberFormat = "mm/dd/yyyy"
    ActiveCell.Select
    Else
    MsgBox "Select a date in 2005/2006"
    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:A20"), 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


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl



    "whowatwerwyhow" <whowatwerwyhow@discussions.microsoft.com> wrote in message
    news:86C22B90-2667-4483-9C34-8F91D2CD8B44@microsoft.com...
    > Hi,
    >
    > I'm trying to use the calendar tool in Forms under the VBAProject so that
    > the years dropdown list only displays the years 2005 and 2006 (instead of all
    > years from 1900 thru to 2100). Is there a way to limit the years to only 2005
    > and 2006?
    >
    > If not, is there a way to display an error message so that the user can be
    > told to enter a date between 2005 and 2006 if they don't? I've got a
    > validation check but this seems to have no effect when the date is entered
    > using the pop-up calendar tool.
    >
    > Thanks in advance.




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1