Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found some code on the Internet that describes how to add
the "Calendar Control 8.0" onto your Excel spreadsheet. It explains to first create a Userform and then to place the control on top of the Userform. The website then explains to paste the following code into your Userform module: Private Sub Calendar1_Click() ActiveCell = Calendar1.Value ActiveCell.NumberFormat="mm/dd/yy" End Sub Private Sub UserForm_Activate() Me.Calendar1.Value = Date End Sub I understand the code for "Calendar1_Click()", but can someone help me understand the code for "UserForm_Activate()"??? I'm not sure why this code is necessary or what it does?? I am able to delete the code in "UserForm_Activate()" and the calendar control still works fine without it, so I just want to know what it does. Thank you! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The _Activate event fires when the form is activated. That can be upon
initial opening of the form or when you have it open, click on some other object, such as a worksheet, and then back to the form. So this is a reset mechanism to set the calendar date back to the system date if you've been twiddling around on another form, worksheet, or other application. And you're right, it will work just fine without that code, you just lose that 'reset' function. Actually, what I'd probably do is to move that line of code into the UserForm_Initialize() routine. That would set the date when the form is loaded, leave it alone while it is in use, and if you use an Unload Me statement anywhere, reset it to the current system date the next time you open the form. "Robert Crandal" wrote: I found some code on the Internet that describes how to add the "Calendar Control 8.0" onto your Excel spreadsheet. It explains to first create a Userform and then to place the control on top of the Userform. The website then explains to paste the following code into your Userform module: Private Sub Calendar1_Click() ActiveCell = Calendar1.Value ActiveCell.NumberFormat="mm/dd/yy" End Sub Private Sub UserForm_Activate() Me.Calendar1.Value = Date End Sub I understand the code for "Calendar1_Click()", but can someone help me understand the code for "UserForm_Activate()"??? I'm not sure why this code is necessary or what it does?? I am able to delete the code in "UserForm_Activate()" and the calendar control still works fine without it, so I just want to know what it does. Thank you! . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It is not necessary to put a Calendar on a UseerForm. You can put it right
on the spreadsheet if you want. Mike F "Robert Crandal" wrote in message ... I found some code on the Internet that describes how to add the "Calendar Control 8.0" onto your Excel spreadsheet. It explains to first create a Userform and then to place the control on top of the Userform. The website then explains to paste the following code into your Userform module: Private Sub Calendar1_Click() ActiveCell = Calendar1.Value ActiveCell.NumberFormat="mm/dd/yy" End Sub Private Sub UserForm_Activate() Me.Calendar1.Value = Date End Sub I understand the code for "Calendar1_Click()", but can someone help me understand the code for "UserForm_Activate()"??? I'm not sure why this code is necessary or what it does?? I am able to delete the code in "UserForm_Activate()" and the calendar control still works fine without it, so I just want to know what it does. Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calendar Control 8.0 question | Excel Programming | |||
click on calendar control calendar but want to return the DAY of | Excel Programming | |||
monthview calendar question/ want the calendar to display weekdays only.. | Excel Programming | |||
Control disappeared problem - specifically, the Calendar Control | Excel Programming | |||
Calendar Control: Can't exit design mode because control can't be created | Excel Programming |