PC Review


Reply
Thread Tools Rate Thread

Calendar control code

 
 
Mike Rogers
Guest
Posts: n/a
 
      24th Nov 2009
I have a calendar pop up using Ron DeBruin’s code. I use this in many of my
spreadsheets and most have always worked as intended. I have two separate
worksheets that now the calendar is changing size each time they are opened.
The mystery is that on one the calendar gets larger, to the point that it
eventually fills the entire viewable screen. The other one gets smaller to
the point that you can’t read the dates on the calendar. Both scroll
properly. I have compared all the calendar properties for both and they are
the same. The code is the same, with the exception of the ranges used and
one does have an added code for placing check marks in a specified range, but
the code for the calendar is the same in both.

Here is the code that is in the worksheet that makes the calendar smaller:

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "ddd mm/dd"
ActiveCell.Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A5:A1520"), Target) Is Nothing Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
' select Today's date in the Calendar
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
End Sub

On several other worksheets this code works fine and has been for a couple
of years.

Here is the code from the worksheet that makes the calendar bigger:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("D4500,J4:J500,M4:M500"), Target)
Is Nothing Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
' select Today's date in the Calendar
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("Checks")) Is Nothing Then
With Target
If .Value = "P" Then
.Value = ""
Else
.Value = "P"
.Font.Name = "Wingdings 2"

End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub

Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "ddd mmm dd"
ActiveCell.Select
End Sub

This code is particular to this one worksheet because I needed the
checkmarks and combined the two macros (cobbled as it may be it does the job).

Any help/direction would be appreciated

Mike Rogers



 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      24th Nov 2009
Hi Mike

Is your Zoom different in that workbook

Sometimes if that is true this will help
Deltee the control
Save the file
Add the control
Save the file



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Mike Rogers" <Mike060349@NoxSpamxAOLDOTcom> wrote in message news:37B5C6CE-0796-4427-B51A-(E-Mail Removed)...
>I have a calendar pop up using Ron DeBruin’s code. I use this in many of my
> spreadsheets and most have always worked as intended. I have two separate
> worksheets that now the calendar is changing size each time they are opened.
> The mystery is that on one the calendar gets larger, to the point that it
> eventually fills the entire viewable screen. The other one gets smaller to
> the point that you can’t read the dates on the calendar. Both scroll
> properly. I have compared all the calendar properties for both and they are
> the same. The code is the same, with the exception of the ranges used and
> one does have an added code for placing check marks in a specified range, but
> the code for the calendar is the same in both.
>
> Here is the code that is in the worksheet that makes the calendar smaller:
>
> Private Sub Calendar1_Click()
> ActiveCell.Value = CDbl(Calendar1.Value)
> ActiveCell.NumberFormat = "ddd mm/dd"
> ActiveCell.Select
> End Sub
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If Target.Cells.Count > 1 Then Exit Sub
> If Not Application.Intersect(Range("A5:A1520"), Target) Is Nothing Then
> Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> Calendar1.Top = Target.Top + Target.Height
> Calendar1.Visible = True
> ' select Today's date in the Calendar
> Calendar1.Value = Date
> ElseIf Calendar1.Visible Then Calendar1.Visible = False
> End If
> End Sub
>
> On several other worksheets this code works fine and has been for a couple
> of years.
>
> Here is the code from the worksheet that makes the calendar bigger:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If Target.Cells.Count > 1 Then Exit Sub
> If Not Application.Intersect(Range("D4500,J4:J500,M4:M500"), Target)
> Is Nothing Then
> Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> Calendar1.Top = Target.Top + Target.Height
> Calendar1.Visible = True
> ' select Today's date in the Calendar
> Calendar1.Value = Date
> ElseIf Calendar1.Visible Then Calendar1.Visible = False
> End If
> Application.EnableEvents = False
> On Error GoTo sub_exit
> If Not Intersect(Target, Range("Checks")) Is Nothing Then
> With Target
> If .Value = "P" Then
> .Value = ""
> Else
> .Value = "P"
> .Font.Name = "Wingdings 2"
>
> End If
> End With
> End If
> sub_exit:
> Application.EnableEvents = True
> End Sub
>
> Private Sub Calendar1_Click()
> ActiveCell.Value = CDbl(Calendar1.Value)
> ActiveCell.NumberFormat = "ddd mmm dd"
> ActiveCell.Select
> End Sub
>
> This code is particular to this one worksheet because I needed the
> checkmarks and combined the two macros (cobbled as it may be it does the job).
>
> Any help/direction would be appreciated
>
> Mike Rogers
>
>
>


 
Reply With Quote
 
Mike Rogers
Guest
Posts: n/a
 
      25th Nov 2009


Ron

Did the Delete code & control>Save>Close>Reopen>Added code and control and
it still has the problem. Here is what I found. Upon placing the control
its properties said it was 138.75 x 307.5. Saved>closed>reopened 5 times.
After the fifth time the control properties said it was now 425.75 X 930.75.
Did not try the other worksheet because it gets smaller (whereas this one
gets larger) at a much slower rate & it is easier to live with. Zoom was
125% each time I opened/closed and remains the same now. Is it possible to
add code to keep the control about the 138.75 X 307.75 size?

Thanks for your time

Mike Rogers

"Ron de Bruin" wrote:

> Hi Mike
>
> Is your Zoom different in that workbook
>
> Sometimes if that is true this will help
> Deltee the control
> Save the file
> Add the control
> Save the file
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Mike Rogers" <Mike060349@NoxSpamxAOLDOTcom> wrote in message news:37B5C6CE-0796-4427-B51A-(E-Mail Removed)...
> >I have a calendar pop up using Ron DeBruin’s code. I use this in many of my
> > spreadsheets and most have always worked as intended. I have two separate
> > worksheets that now the calendar is changing size each time they are opened.
> > The mystery is that on one the calendar gets larger, to the point that it
> > eventually fills the entire viewable screen. The other one gets smaller to
> > the point that you can’t read the dates on the calendar. Both scroll
> > properly. I have compared all the calendar properties for both and they are
> > the same. The code is the same, with the exception of the ranges used and
> > one does have an added code for placing check marks in a specified range, but
> > the code for the calendar is the same in both.
> >
> > Here is the code that is in the worksheet that makes the calendar smaller:
> >
> > Private Sub Calendar1_Click()
> > ActiveCell.Value = CDbl(Calendar1.Value)
> > ActiveCell.NumberFormat = "ddd mm/dd"
> > ActiveCell.Select
> > End Sub
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > If Target.Cells.Count > 1 Then Exit Sub
> > If Not Application.Intersect(Range("A5:A1520"), Target) Is Nothing Then
> > Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> > Calendar1.Top = Target.Top + Target.Height
> > Calendar1.Visible = True
> > ' select Today's date in the Calendar
> > Calendar1.Value = Date
> > ElseIf Calendar1.Visible Then Calendar1.Visible = False
> > End If
> > End Sub
> >
> > On several other worksheets this code works fine and has been for a couple
> > of years.
> >
> > Here is the code from the worksheet that makes the calendar bigger:
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > If Target.Cells.Count > 1 Then Exit Sub
> > If Not Application.Intersect(Range("D4500,J4:J500,M4:M500"), Target)
> > Is Nothing Then
> > Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> > Calendar1.Top = Target.Top + Target.Height
> > Calendar1.Visible = True
> > ' select Today's date in the Calendar
> > Calendar1.Value = Date
> > ElseIf Calendar1.Visible Then Calendar1.Visible = False
> > End If
> > Application.EnableEvents = False
> > On Error GoTo sub_exit
> > If Not Intersect(Target, Range("Checks")) Is Nothing Then
> > With Target
> > If .Value = "P" Then
> > .Value = ""
> > Else
> > .Value = "P"
> > .Font.Name = "Wingdings 2"
> >
> > End If
> > End With
> > End If
> > sub_exit:
> > Application.EnableEvents = True
> > End Sub
> >
> > Private Sub Calendar1_Click()
> > ActiveCell.Value = CDbl(Calendar1.Value)
> > ActiveCell.NumberFormat = "ddd mmm dd"
> > ActiveCell.Select
> > End Sub
> >
> > This code is particular to this one worksheet because I needed the
> > checkmarks and combined the two macros (cobbled as it may be it does the job).
> >
> > Any help/direction would be appreciated
> >
> > Mike Rogers
> >
> >
> >

>
> .
>

 
Reply With Quote
 
Mike Rogers
Guest
Posts: n/a
 
      25th Nov 2009
Ron

The zoom is the same on both, but I will try your suggestion and post back.

I was thinking about addiing the necessary code to have the control be the
same size upon opening......

I'll give it a try and post back, Thanks

Mike Rogers




"Ron de Bruin" wrote:

> Hi Mike
>
> Is your Zoom different in that workbook
>
> Sometimes if that is true this will help
> Deltee the control
> Save the file
> Add the control
> Save the file
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Mike Rogers" <Mike060349@NoxSpamxAOLDOTcom> wrote in message news:37B5C6CE-0796-4427-B51A-(E-Mail Removed)...
> >I have a calendar pop up using Ron DeBruin’s code. I use this in many of my
> > spreadsheets and most have always worked as intended. I have two separate
> > worksheets that now the calendar is changing size each time they are opened.
> > The mystery is that on one the calendar gets larger, to the point that it
> > eventually fills the entire viewable screen. The other one gets smaller to
> > the point that you can’t read the dates on the calendar. Both scroll
> > properly. I have compared all the calendar properties for both and they are
> > the same. The code is the same, with the exception of the ranges used and
> > one does have an added code for placing check marks in a specified range, but
> > the code for the calendar is the same in both.
> >
> > Here is the code that is in the worksheet that makes the calendar smaller:
> >
> > Private Sub Calendar1_Click()
> > ActiveCell.Value = CDbl(Calendar1.Value)
> > ActiveCell.NumberFormat = "ddd mm/dd"
> > ActiveCell.Select
> > End Sub
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > If Target.Cells.Count > 1 Then Exit Sub
> > If Not Application.Intersect(Range("A5:A1520"), Target) Is Nothing Then
> > Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> > Calendar1.Top = Target.Top + Target.Height
> > Calendar1.Visible = True
> > ' select Today's date in the Calendar
> > Calendar1.Value = Date
> > ElseIf Calendar1.Visible Then Calendar1.Visible = False
> > End If
> > End Sub
> >
> > On several other worksheets this code works fine and has been for a couple
> > of years.
> >
> > Here is the code from the worksheet that makes the calendar bigger:
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > If Target.Cells.Count > 1 Then Exit Sub
> > If Not Application.Intersect(Range("D4500,J4:J500,M4:M500"), Target)
> > Is Nothing Then
> > Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
> > Calendar1.Top = Target.Top + Target.Height
> > Calendar1.Visible = True
> > ' select Today's date in the Calendar
> > Calendar1.Value = Date
> > ElseIf Calendar1.Visible Then Calendar1.Visible = False
> > End If
> > Application.EnableEvents = False
> > On Error GoTo sub_exit
> > If Not Intersect(Target, Range("Checks")) Is Nothing Then
> > With Target
> > If .Value = "P" Then
> > .Value = ""
> > Else
> > .Value = "P"
> > .Font.Name = "Wingdings 2"
> >
> > End If
> > End With
> > End If
> > sub_exit:
> > Application.EnableEvents = True
> > End Sub
> >
> > Private Sub Calendar1_Click()
> > ActiveCell.Value = CDbl(Calendar1.Value)
> > ActiveCell.NumberFormat = "ddd mmm dd"
> > ActiveCell.Select
> > End Sub
> >
> > This code is particular to this one worksheet because I needed the
> > checkmarks and combined the two macros (cobbled as it may be it does the job).
> >
> > Any help/direction would be appreciated
> >
> > Mike Rogers
> >
> >
> >

>
> .
>

 
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
Code for Calendar control Ram Microsoft Excel Programming 2 9th Jul 2007 03:17 PM
Changing the selecteddate of a calendar control in code Jason James Microsoft ASP .NET 2 2nd Jul 2006 01:47 PM
Calendar control is set in JavaScript - how do I get at it in my code behind page? UJ Microsoft ASP .NET 0 20th Apr 2006 10:31 PM
How do I code a command button to open a calendar control on form =?Utf-8?B?SmFtZXMgSm9obnNvbg==?= Microsoft Access Form Coding 1 30th Jun 2005 10:15 AM
Calendar Control - Subform only refreshes when I click into it after choosing date on Control acs68 Microsoft Access Form Coding 1 6th May 2005 11:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 PM.