Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Calendar question

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Calendar question

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Calendar question

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Calendar question

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
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 question? Mekinnik Excel Programming 5 January 10th 08 09:00 PM
monthview calendar question/ want the calendar to display weekdays only.. [email protected] Excel Programming 0 August 26th 07 09:25 PM
calendar question Oldjay Excel Programming 3 October 29th 06 05:15 PM
Calendar Question D Excel Discussion (Misc queries) 12 December 19th 05 05:06 PM
Calendar question Patrick Simonds Excel Programming 1 December 11th 03 04:38 AM


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

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

About Us

"It's about Microsoft Excel"