Professional Documents
Culture Documents
2 Develope
This custom date picker can be used by importing the CalendarForm.frm file into your VBA project. It is called exclus
For instructions on how to call on the CalendarForm, skip to the GetDate function documentation on the Us
Overview
The goal in creating this form was first and foremost to overcome the monstrosity that is the Microsoft MonthView c
probably already know what I'm talking about. Many others have been in my place and have come up with their own
So why yet another custom date picker?
Since none of the date pickers I have been able to find in all my searching have quite completed my checklist, here w
other tired soul may also benefit from my labors.
If you encounter any bugs, or have any great ideas or feature requests that could improve this bad boy, please send m
Developed by Trevor Eyre (trevoreyre@gmail.com)
The GetDate function is the point of entry into the CalendarForm. It controls EVERYTHING. Every argument is optiona
be as simple as dateVariable = CalendarForm.GetDate.
That's all there is to it. The calendar initializes, pops up, the user selects a date, the selection is received by your varia
Try it out! Click the calendar to select a date to show in the box.
VBA Code
###
Sub BasicCalendar()
January 7, 2016 dateVariable = Calend
If dateVariable <> 0 T
End Sub
From there, you can use as many or as few arguments as you want in order to get the desired calendar that suits you
set in the GetDate function, so if you want to change default colors or behavior without having to explicitly do so in e
those values in the argument list for the function.
By setting the various arguments, you can obtain vastly different calendars, all with the same function. Below is an ex
different settings, including week numbers, a different first day of the week, and a customized color scheme.
VBA Code
Below is another example of ways you can customize the look and feel of your calendar.
VBA Code
For a complete list of arguments, their data type, and a description of its function, go to the GetDate Arguments tab
documented in the CalendarForm userform itself.
Developed by Trevor Eyre (trevoreyre@gmail.com)
Sub BasicCalendar()
dateVariable = CalendarForm.GetDate
If dateVariable <> 0 Then Range("H16") = dateVariable
End Sub
d calendar that suits your needs. All default values are also
ng to explicitly do so in every function call, you can set
b AdvancedCalendar()
dateVariable = CalendarForm.GetDate( _
SelectedDate:=Range("H34").Value, _
FirstDayOfWeek:=Monday, _
DateFontSize:=12, _
TodayButton:=True, _
OkayButton:=True, _
ShowWeekNumbers:=True, _
BackgroundColor:=RGB(243, 249, 251), _
HeaderColor:=RGB(147, 205, 2221), _
HeaderFontColor:=RGB(255, 255, 255), _
SubHeaderColor:=RGB(223, 240, 245), _
SubHeaderFontColor:=RGB(31, 78, 120), _
DateColor:=RGB(243, 249, 251), _
DateFontColor:=RGB(31, 78, 120), _
TrailingMonthFontColor:=RGB(155, 194, 230), _
DateHoverColor:=RGB(223, 240, 245), _
DateSelectedColor:=RGB(202, 223, 242), _
SaturdayFontColor:=RGB(0, 176, 240), _
SundayFontColor:=RGB(0, 176, 240), _
TodayFontColor:=RGB(0, 176, 80))
f dateVariable <> 0 Then Range("H34") = dateVariable
SubHeaderColor:=RGB(223, 240, 245), _
SubHeaderFontColor:=RGB(31, 78, 120), _
DateColor:=RGB(243, 249, 251), _
DateFontColor:=RGB(31, 78, 120), _
TrailingMonthFontColor:=RGB(155, 194, 230), _
DateHoverColor:=RGB(223, 240, 245), _
DateSelectedColor:=RGB(202, 223, 242), _
SaturdayFontColor:=RGB(0, 176, 240), _
SundayFontColor:=RGB(0, 176, 240), _
TodayFontColor:=RGB(0, 176, 80))
f dateVariable <> 0 Then Range("H34") = dateVariable
d Sub
b AdvancedCalendar2()
dateVariable = CalendarForm.GetDate( _
SelectedDate:=Range("H61").Value, _
DateFontSize:=11, _
TodayButton:=True, _
BackgroundColor:=RGB(242, 248, 238), _
HeaderColor:=RGB(84, 130, 53), _
HeaderFontColor:=RGB(255, 255, 255), _
SubHeaderColor:=RGB(226, 239, 218), _
SubHeaderFontColor:=RGB(55, 86, 35), _
DateColor:=RGB(242, 248, 238), _
DateFontColor:=RGB(55, 86, 35), _
SaturdayFontColor:=RGB(55, 86, 35), _
SundayFontColor:=RGB(55, 86, 35), _
TrailingMonthFontColor:=RGB(106, 163, 67), _
DateHoverColor:=RGB(198, 224, 180), _
DateSelectedColor:=RGB(169, 208, 142), _
TodayFontColor:=RGB(255, 0, 0), _
DateSpecialEffect:=fmSpecialEffectRaised)
f dateVariable <> 0 Then Range("H61") = dateVariable
d Sub
GetDate Arguments
Below is a list of all arguments in the GetDate function, their data type, and their function. Remember that every arg
meaning you can use as many or as few as you want to meet your needs.
SelectedDate (Date) - This is the initial selected date on the calendar. Used to show the users last selection. If this va
to the month and year of the SelectedDate. If not, it will initialize to today's date (with no selection).
FirstDayOfWeek (calDayOfWeek) - Sets which day to use as first day of the week.
MinimumDate (Date) - Restricts the selection of any dates below this date.
MaximumDate (Date) - Restricts the selection of any dates above this date.
###
RangeOfYears (Long) - Sets the range of years to show in the year combobox in either direction from the initial Selec
SelectedDate is in 2014, and the RangeOfYears is set to 10 (the default value), the year combobox will show 10 years
2014, so it will have a range of 2004-2024. Note that if this range falls outside the bounds set by the MinimumDate o
overridden. Also, this range does NOT limit the years that a user can select. If the upper limit of the year combobox i
month spinner to surpass December 2024, it will keep right on going to 2025 and beyond (and those years will be ad
DateFontSize (Long) - Controls the size of the CalendarForm. This value cannot be set below 9 (the default). To make
larger, and everything else in the userform will be resized to fit.
OkayButton (Boolean) - Controls whether or not the Okay button is visible. If the Okay button is enabled, when the u
but is not returned until they click Okay. If the Okay button is disabled, clicking a date will automatically return that d
FirstWeekOfYear (calFirstWeekOfYear) - Controls which week in January is calculated as week 1. See the calFirstWee
Variables section of the CalendarForm to see the possible values and their behavior.
PositionTop (Long) - Sets the top position of the CalendarForm. If no value is assigned, the CalendarForm is set to po
PositionTop and PositionLeft must BOTH be set in order to override the default center position.
PositionLeft (Long) - Sets the left position of the CalendarForm. If no value is assigned, the CalendarForm is set to po
PositionTop and PositionLeft must BOTH be set in order to override the default center position.
###
BackgroundColor (Long) - Sets the background color of the CalendarForm.
HeaderColor (Long) - Sets the background color of the header. The header is the month and year label at the top.
SubHeaderColor (Long) - Sets the background color of the subheader. The subheader is the day of week labels under
DateColor (Long) - Sets the background color of the individual date labels.
DateFontColor (Long) - Sets the font color of the individual date labels.
DateBorder (Boolean) - Controls whether or not the date labels have borders.
DateBorderColor (Long) - Sets the color of the date label borders. Note that the argument DateBorder must be set to
DateFontColor (Long) - Sets the font color of the individual date labels.
DateBorder (Boolean) - Controls whether or not the date labels have borders.
DateBorderColor (Long) - Sets the color of the date label borders. Note that the argument DateBorder must be set to
DateSpecialEffect (fmSpecialEffect) - Sets a special effect for the date labels. This can be set to bump, etched, flat (de
can be used to make the date labels look like buttons if you desire. Note that this setting overrides any date border s
DateHoverColor (Long) - Sets the background color when hovering the mouse over a date label.
TrailingMonthFontColor (Long) - Sets the color of the date labels in trailing months. Trailing months are the date labe
the calendar and from next month at the bottom of the calendar.
day of week labels under the header (Su, Mo, Tu, etc).
bel.
months are the date labels from last month at the top of