PC Review


Reply
Thread Tools Rate Thread

Calendar question

 
 
Patrick C. Simonds
Guest
Posts: n/a
 
      3rd Aug 2008
I was going to use the code below to set the Calendar during UserForm
initialization but I realized that if rng(1, 4).Value = blank that I
wanted the calendar to open with the correct month and year but no day
selected.

If I eliminate the If rng(1, 4).Value = "" Then
Calendar2.Value = Now()

The Calendar will open with no day selected, but it will not necessarily
come up with the proper month and year (I tried resetting the date on my
compute and the Calendar did not come up with the correct month or year).


Current Code:

If rng(1, 4).Value = "" Then
Calendar2.Value = Now()
Else
Calendar2.Value = rng(1, 4).Value
End If

 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      3rd Aug 2008
try using = Date()

"Patrick C. Simonds" wrote:

> I was going to use the code below to set the Calendar during UserForm
> initialization but I realized that if rng(1, 4).Value = blank that I
> wanted the calendar to open with the correct month and year but no day
> selected.
>
> If I eliminate the If rng(1, 4).Value = "" Then
> Calendar2.Value = Now()
>
> The Calendar will open with no day selected, but it will not necessarily
> come up with the proper month and year (I tried resetting the date on my
> compute and the Calendar did not come up with the correct month or year).
>
>
> Current Code:
>
> If rng(1, 4).Value = "" Then
> Calendar2.Value = Now()
> Else
> Calendar2.Value = rng(1, 4).Value
> End If
>
>

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      3rd Aug 2008
sorry disregaurd what i have posted

"Mike" wrote:

> try using = Date()
>
> "Patrick C. Simonds" wrote:
>
> > I was going to use the code below to set the Calendar during UserForm
> > initialization but I realized that if rng(1, 4).Value = blank that I
> > wanted the calendar to open with the correct month and year but no day
> > selected.
> >
> > If I eliminate the If rng(1, 4).Value = "" Then
> > Calendar2.Value = Now()
> >
> > The Calendar will open with no day selected, but it will not necessarily
> > come up with the proper month and year (I tried resetting the date on my
> > compute and the Calendar did not come up with the correct month or year).
> >
> >
> > Current Code:
> >
> > If rng(1, 4).Value = "" Then
> > Calendar2.Value = Now()
> > Else
> > Calendar2.Value = rng(1, 4).Value
> > End If
> >
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Aug 2008
Maybe (if correct means the current month and year)...

Option Explicit
Private Sub UserForm_Initialize()
Dim rng As Range
Set rng = Worksheets("sheet1").Range("a1")

If rng(1, 4).Value = "" Then
With Me.Calendar2
.Month = Month(Date)
.Year = Year(Date)
.Day = 0
End With
Else
Me.Calendar2.Value = rng(1, 4).Value
End If
End Sub

"Patrick C. Simonds" wrote:
>
> I was going to use the code below to set the Calendar during UserForm
> initialization but I realized that if rng(1, 4).Value = blank that I
> wanted the calendar to open with the correct month and year but no day
> selected.
>
> If I eliminate the If rng(1, 4).Value = "" Then
> Calendar2.Value = Now()
>
> The Calendar will open with no day selected, but it will not necessarily
> come up with the proper month and year (I tried resetting the date on my
> compute and the Calendar did not come up with the correct month or year).
>
> Current Code:
>
> If rng(1, 4).Value = "" Then
> Calendar2.Value = Now()
> Else
> Calendar2.Value = rng(1, 4).Value
> End If


--

Dave Peterson
 
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
monthview calendar question/ want the calendar to display weekdays only.. greg@christiancarpets.com Microsoft Excel Programming 0 26th Aug 2007 09:25 PM
calendar question =?Utf-8?B?bmV3eW9ya2pveQ==?= Microsoft Outlook Discussion 3 15th Jun 2007 09:56 PM
calendar question... bsurace Microsoft Excel Discussion 2 21st Jul 2006 08:40 PM
Feasibility Question: Possible to pull Calendar Items from shared calendar? Paul Thompson Microsoft Outlook VBA Programming 1 4th May 2004 12:53 PM
Calendar question Jeff Malka Microsoft Outlook Discussion 2 6th Jan 2004 08:23 PM


Features
 

Advertising
 

Newsgroups
 


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