Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default 2nd question - Calendar Control 8.0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default 2nd question - Calendar Control 8.0

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default 2nd question - Calendar Control 8.0

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
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
Calendar Control 8.0 question Robert Crandal Excel Programming 7 November 25th 09 09:41 PM
click on calendar control calendar but want to return the DAY of retired bill Excel Programming 13 May 9th 09 01:57 AM
monthview calendar question/ want the calendar to display weekdays only.. [email protected] Excel Programming 0 August 26th 07 09:25 PM
Control disappeared problem - specifically, the Calendar Control JMMach[_2_] Excel Programming 0 December 16th 05 01:53 AM
Calendar Control: Can't exit design mode because control can't be created Rone Excel Programming 0 May 24th 04 04:01 PM


All times are GMT +1. The time now is 12:01 AM.

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

About Us

"It's about Microsoft Excel"