PC Review


Reply
Thread Tools Rate Thread

Calendar default date

 
 
callbr549
Guest
Posts: n/a
 
      7th Jan 2009
I have a userform with several objects on it including a calendar. I can't
figure out how to have the calendar default to the current date when the
userform is opened. Something I read somewhere said you have to do something
like Calendar1.value=Date, but I can't figure out where to put that line of
code. On another forum it described putting it in the Initialize event for
the calendar, but I can't find an Initialize for the calendar.
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      7th Jan 2009
What about the Initialize event for the UserForm?

--
Rick (MVP - Excel)


"callbr549" <(E-Mail Removed)> wrote in message
news9082F58-FDF9-4DC9-86C2-(E-Mail Removed)...
>I have a userform with several objects on it including a calendar. I can't
> figure out how to have the calendar default to the current date when the
> userform is opened. Something I read somewhere said you have to do
> something
> like Calendar1.value=Date, but I can't figure out where to put that line
> of
> code. On another forum it described putting it in the Initialize event for
> the calendar, but I can't find an Initialize for the calendar.


 
Reply With Quote
 
callbr549
Guest
Posts: n/a
 
      7th Jan 2009
I feel pretty stupid asking this, but I can't seem to find the Initialize
event for the UserForm. I have the form opening with a Command Button that
has UserForm1.Open in its Click event. I've tried putting the Calendar1.value
= Date code there, but get errors. Looking for the Initialize event -- I
select the UserForm in the Project pane, then View|Code, then look for
UserForm1 in the top left pulldown menu on the right hand side pane. I don't
see UserForm1 there. It lists Calendar1 there, but when I select it it
doesn't list an Initialize event in the right hand side pulldown menu. (I
hope this makes some sense).

Thanks,
Rob Samples

"Rick Rothstein" wrote:

> What about the Initialize event for the UserForm?
>
> --
> Rick (MVP - Excel)
>
>
> "callbr549" <(E-Mail Removed)> wrote in message
> news9082F58-FDF9-4DC9-86C2-(E-Mail Removed)...
> >I have a userform with several objects on it including a calendar. I can't
> > figure out how to have the calendar default to the current date when the
> > userform is opened. Something I read somewhere said you have to do
> > something
> > like Calendar1.value=Date, but I can't figure out where to put that line
> > of
> > code. On another forum it described putting it in the Initialize event for
> > the calendar, but I can't find an Initialize for the calendar.

>
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      7th Jan 2009
Click on UserForm in the list... it has the Initialize event. UserForm1 is
your name for that module in case you need to reference it in code, but the
module itself is UserForm (look at the event procedures for the UserForm...
none of them use the name you gave it, they all say UserForm.

--
Rick (MVP - Excel)


"callbr549" <(E-Mail Removed)> wrote in message
news:9D673362-41BA-4226-837B-(E-Mail Removed)...
>I feel pretty stupid asking this, but I can't seem to find the Initialize
> event for the UserForm. I have the form opening with a Command Button
> that
> has UserForm1.Open in its Click event. I've tried putting the
> Calendar1.value
> = Date code there, but get errors. Looking for the Initialize event -- I
> select the UserForm in the Project pane, then View|Code, then look for
> UserForm1 in the top left pulldown menu on the right hand side pane. I
> don't
> see UserForm1 there. It lists Calendar1 there, but when I select it it
> doesn't list an Initialize event in the right hand side pulldown menu. (I
> hope this makes some sense).
>
> Thanks,
> Rob Samples
>
> "Rick Rothstein" wrote:
>
>> What about the Initialize event for the UserForm?
>>
>> --
>> Rick (MVP - Excel)
>>
>>
>> "callbr549" <(E-Mail Removed)> wrote in message
>> news9082F58-FDF9-4DC9-86C2-(E-Mail Removed)...
>> >I have a userform with several objects on it including a calendar. I
>> >can't
>> > figure out how to have the calendar default to the current date when
>> > the
>> > userform is opened. Something I read somewhere said you have to do
>> > something
>> > like Calendar1.value=Date, but I can't figure out where to put that
>> > line
>> > of
>> > code. On another forum it described putting it in the Initialize event
>> > for
>> > the calendar, but I can't find an Initialize for the calendar.

>>
>>


 
Reply With Quote
 
callbr549
Guest
Posts: n/a
 
      7th Jan 2009
Excellent answer. Your explanation made things very clear. Calendar now does
exactly what I wanted it to do. Thank you very much.

"Rick Rothstein" wrote:

> Click on UserForm in the list... it has the Initialize event. UserForm1 is
> your name for that module in case you need to reference it in code, but the
> module itself is UserForm (look at the event procedures for the UserForm...
> none of them use the name you gave it, they all say UserForm.
>
> --
> Rick (MVP - Excel)
>
>
> "callbr549" <(E-Mail Removed)> wrote in message
> news:9D673362-41BA-4226-837B-(E-Mail Removed)...
> >I feel pretty stupid asking this, but I can't seem to find the Initialize
> > event for the UserForm. I have the form opening with a Command Button
> > that
> > has UserForm1.Open in its Click event. I've tried putting the
> > Calendar1.value
> > = Date code there, but get errors. Looking for the Initialize event -- I
> > select the UserForm in the Project pane, then View|Code, then look for
> > UserForm1 in the top left pulldown menu on the right hand side pane. I
> > don't
> > see UserForm1 there. It lists Calendar1 there, but when I select it it
> > doesn't list an Initialize event in the right hand side pulldown menu. (I
> > hope this makes some sense).
> >
> > Thanks,
> > Rob Samples
> >
> > "Rick Rothstein" wrote:
> >
> >> What about the Initialize event for the UserForm?
> >>
> >> --
> >> Rick (MVP - Excel)
> >>
> >>
> >> "callbr549" <(E-Mail Removed)> wrote in message
> >> news9082F58-FDF9-4DC9-86C2-(E-Mail Removed)...
> >> >I have a userform with several objects on it including a calendar. I
> >> >can't
> >> > figure out how to have the calendar default to the current date when
> >> > the
> >> > userform is opened. Something I read somewhere said you have to do
> >> > something
> >> > like Calendar1.value=Date, but I can't figure out where to put that
> >> > line
> >> > of
> >> > code. On another forum it described putting it in the Initialize event
> >> > for
> >> > the calendar, but I can't find an Initialize for the calendar.
> >>
> >>

>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      7th Jan 2009
Rob

Sample code.

Private Sub cmdClose_Click()
' Close the UserForm
Unload Me
End Sub

Private Sub UserForm_Initialize()
' Check if active cell contains a date. If 'yes' show
' same date on calendar. If 'no' show today's date.
If IsDate(ActiveCell.Value) Then
Calendar1.Value = DateValue(ActiveCell.Value)
Else
Calendar1.Value = Format(Date, "dd-mmm-yy")
End If
End Sub

Private Sub Calendar1_Click()
' Transfer date selected on calendar to active cell
' and close UserForm.
ActiveCell.Value = Format(Calendar1.Value, "dd-mmm-yy")
Unload Me
End Sub


Gord Dibben MS Excel MVP


On Wed, 7 Jan 2009 09:09:02 -0800, callbr549
<(E-Mail Removed)> wrote:

>I feel pretty stupid asking this, but I can't seem to find the Initialize
>event for the UserForm. I have the form opening with a Command Button that
>has UserForm1.Open in its Click event. I've tried putting the Calendar1.value
>= Date code there, but get errors. Looking for the Initialize event -- I
>select the UserForm in the Project pane, then View|Code, then look for
>UserForm1 in the top left pulldown menu on the right hand side pane. I don't
>see UserForm1 there. It lists Calendar1 there, but when I select it it
>doesn't list an Initialize event in the right hand side pulldown menu. (I
>hope this makes some sense).
>
>Thanks,
>Rob Samples
>
>"Rick Rothstein" wrote:
>
>> What about the Initialize event for the UserForm?
>>
>> --
>> Rick (MVP - Excel)
>>
>>
>> "callbr549" <(E-Mail Removed)> wrote in message
>> news9082F58-FDF9-4DC9-86C2-(E-Mail Removed)...
>> >I have a userform with several objects on it including a calendar. I can't
>> > figure out how to have the calendar default to the current date when the
>> > userform is opened. Something I read somewhere said you have to do
>> > something
>> > like Calendar1.value=Date, but I can't figure out where to put that line
>> > of
>> > code. On another forum it described putting it in the Initialize event for
>> > the calendar, but I can't find an Initialize for the calendar.

>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar Default Date =?Utf-8?B?c3dlZGJlcmE=?= Microsoft Access 4 7th Apr 2006 12:44 PM
Calendar & Default Date =?Utf-8?B?c3dlZGJlcmE=?= Microsoft Access 1 3rd Apr 2006 04:43 PM
Default Date in 30 Day Calendar Microsoft Outlook Calendar 1 31st Aug 2004 11:08 PM
Default date in calendar Eric Microsoft Outlook Calendar 1 31st Aug 2004 08:16 PM
Calendar default date clayton Microsoft Excel Misc 2 13th Feb 2004 05:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:30 PM.