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

G'day there People,

I've modified the calendar that John Walkenbach built with an
Array Formula. As he suggested in his book, I've modified it so that the
dates of previous & next months are also displayed, however they are in
a different font colour.

I've also built myself a userform which duplicates the calendar
using commandbuttons for the date cells. I have the both sets of scroll
bars pointing to the same ControlSource, so both should work
simultaneously. What I want is for the user to adjust the month, or
year, on the userfomr and have both calendars change together or use the
worksheet one alone. At the moment, the userform works as planned but
the update is delayed until I click one of the buttons on the userform.
Then both calendars update.

I've tried placing the code to call the update routines in various
places, but only in the AfterUpdate event does it actually update both
the worksheet & the userform details. However it still only does it when
I click another button. How can I get it to update when the scroll bar
is clicked?

Thanks in advance,
Ken McLennan
Qld, Australia

Here is the code I'm using:

################################################## ##
In the Userform:

Option Explicit

Private Sub cmbCancel_Click()
Unload Me
End Sub

Private Sub ScrollBar2_AfterUpdate()
Worksheets("Calendar").Calculate
calUpdte
End Sub

Private Sub ScrollBar3_AfterUpdate()
Worksheets("Calendar").Calculate
calUpdte
End Sub

Private Sub UserForm_Activate()
' All variables declared in main module to facilitate use by public
subroutines
'
' Get custom list (Month) values into array
listArray = Application.GetCustomListContents(4)
Set mth = Worksheets("Calendar").Range("m")
Set yr = Worksheets("Calendar").Range("y")
' Call routine to update Calendar "Day" values on cmdBtns and
month/year display on textbox
calUpdte
End Sub

Private Sub UserForm_Initialize()
' Declare variables as required. In this case...
' Declare a Control objecttype
Dim ctl As Control
' Step through each control on form
For Each ctl In Me.Controls
' If the control's name starts with "Comm"...
' All cmdButtons not to be in UDF Class have had their names
changed
' to preclude selection
If Left(ctl.Name, 4) = "Comm" Then
' shftBtns is an array of type object which is declared with
30 members
' in the Declarations section of the standard module.
' Each cmdButton name is of the form "CommandButtonXX" where
XX is the
' number of the button starting at 1 and both contiguous and
consecutive
' until 30. This number part is extracted from the cmdButton
name String,
' converted to a number and used to point to an entry in the
array of
' controls. This entry then has the control assigned to it.
Set dateBtns(Val(Mid(ctl.Name, 14, Len(ctl.Name)))).btnGroup
= ctl
End If
' Do I need to explain??
Next ctl

End Sub

################################################## #
In a general module:

Sub calUpdte()

' Copy Calendar "Day" values to command button captions
Dim x As Integer
Dim y As Integer
For y = 1 To 6
For x = 1 To 7
dateBtns(((y * 7) + x) - 7).btnGroup.Caption =
[calArray].Cells(y, x).Text
dateBtns(((y * 7) + x) - 7).btnGroup.ForeColor =
[calArray].Cells(y, x).Font.Color
dateBtns(((y * 7) + x) - 7).btnGroup.Font.Bold =
[calArray].Cells(y, x).Font.Bold
Next x
Next y
frmCalendar.TextBox1.Value = listArray(Worksheets("Calendar").Range
("m").Value) & " " & yr
End Sub

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
UserForm: force to update controlsources Gabor Excel Programming 0 August 8th 04 03:01 AM
Need help on Update Button on Userform marty6[_17_] Excel Programming 2 May 16th 04 02:29 PM
Dynamic update of UserForm TextBox Tom_C Excel Programming 7 January 15th 04 06:58 PM
How can I update the userform? Phillips Excel Programming 1 November 21st 03 05:33 PM
UserForm Update on the Fly Nigel[_4_] Excel Programming 2 October 15th 03 06:23 PM


All times are GMT +1. The time now is 02:09 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"