Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouping Dates in a Pivot table for years that are not calendar ye Uno Excel Worksheet Functions 1 June 4th 08 02:57 PM
how do i export excel calendar info to outlook calendar? Maggie Excel Discussion (Misc queries) 1 December 31st 07 10:27 PM
How do I add an extra day to a calendar every four years paddymack New Users to Excel 3 May 31st 05 10:00 AM
excel calendar years whowatwerwyhow Excel Discussion (Misc queries) 1 May 16th 05 12:28 PM
excel calendar years whowatwerwyhow Excel Discussion (Misc queries) 0 May 16th 05 12:19 PM


All times are GMT +1. The time now is 08:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"