LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Calendar mod

G'day there again,

Leaving aside the simultaneous updating mentioned in a previous
thread, I've found that the worksheet calendar from John Walkenbach's
book is causing me problems. I've modified it, as per John's suggestion,
to show dates for the entire work area. That is, I've removed the If
function from the array formula and so have 42 dates shown. All else is
the same as the original.

What I've also done is to place code in the Worksheet_Calculate()
event to check the month of the date shown. If the date is in the
current month, then the forecolor is blue & bold. If it's in the
previous or next month, it's not bold and coloured black. Now here's the
puzzling bit:

If I change the date using the scroll bars on top of the calendar,
the cells are updated with the required formatting. Hence the
Worksheet_Calculate() event code is working. However, if I press the
"Current Month" button, the code hangs with a "Runtime error 1004...
Unable to set the Color property of the Font class" message. Likewise,
the same error is generated from trying to "get" the color property in
the immediate window.

Why is that? the code is the same, the only difference that I can
see is that the setting of month & year are done programatically by
calling a general module to change the scrollbars instead of clicking on
them. The Worksheet_Calculate() code is still called, except that now it
can't do anything with the .font properties.

Here is the Worksheet_Calculate() code:

Note that one uses [calarray], the other uses Me.Range...
just to demonstrate that I've used both types of reference. Same problem
with both methods. ( 'calarray' is the range of the 42 "date" cells in
the calendar)

Private Sub Worksheet_Calculate()
Dim X As Integer
Dim Y As Integer
For Y = 1 To 6
For X = 1 To 7
If Month([calarray].Cells(Y, X).Value) < Me.Range
("m").Value Then
With [calarray].Cells(Y, X).Font
.Color = vbBlack
.Bold = False
End With
Else
With Me.Range("calarray").Cells(Y, X).Font
.Color = vbBlue
.Bold = True
End With
End If
Next X
Next Y

End Sub

Hoping for a suggestion,
Ken McLennan
Qld, Australia
 
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
Convert date from Gregorian Calendar to Hijri Calendar H.Alkhodary Excel Discussion (Misc queries) 1 February 21st 09 10:11 AM
find free sharware to include calendar pop or use calendar in cell ednc Excel Discussion (Misc queries) 2 April 14th 08 05:05 PM
how do i export excel calendar info to outlook calendar? Maggie Excel Discussion (Misc queries) 1 December 31st 07 10:27 PM
excel calendar - list of names displayed on calendar Brian'88 Excel Worksheet Functions 3 November 17th 06 10:31 PM
import calendar items from excel into outlook calendar jsewaiseh Excel Discussion (Misc queries) 0 September 2nd 05 03:53 PM


All times are GMT +1. The time now is 10:31 AM.

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"