Results 1 to 32 of 32

Thread: Calendar Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Red face Calendar Help

    Hi, I need help with my calendar, the code is attached, any help or examples I will be grateful for, as I don’t know where I am going wrong,


    pls and thanx
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    what part does not work?
    what result do you want?

    are the addins anything to do with your code, or just examples for you to work form?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Hi,

    the tm vb calendar is an example the other named "Calendar" is my code,
    the what part does not work....is the sub "Private Sub initfrmCalendar()" its giving an error.

    what result do you want...... well a working calendar would be nice just dont know how to get past the error


    Ta

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    when i started the userform i got no error, i could click a date button and get the caption returned in a messagebox
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    yep cool, thats what its meant to do for now, but at my end its giving an error, for the txtday in "Private Sub initfrmCalendar()" saying wrong number of agruments, to get the error play and click the cbomonth box,

    Any help in this matter?

    ta
    Last edited by helen85; Dec 27th, 2009 at 03:50 PM.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    actually you have a large number of errors so you will just have to figure how to fix some of them, some i have found

    txtday is a single textbox, not an array, so it has no index
    txtDay(iStartIndex).Enabled = True
    this applies in several places
    you need to be working with the collection of the class

    you can select the month combo with no valid year, this cause a type mismatch, when trying to get iStartindex

    in a couple of places you try to set the text property of a control that is a command button, use its caption property

    that is all i have time for at the moment
    fix some of those, then repost your updated work book, no need for the xla files
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Hi, ok the buttons do have an index property allready, heres the code, half on the form and half in a class. And also this is the collection of the class,

    Code:
    Set ctlCB = New cCB
    ctlCB.Init txtDay, Me
    colCB.Add ctlCB
    
    Set ctlCB = New cCB
    ctlCB.Init txtDay2, Me
    colCB.Add ctlCB
    
    Set ctlCB = New cCB
    ctlCB.Init txtDay3, Me
    colCB.Add ctlCB
    Code:
    Private WithEvents m_CB As MSForms.CommandButton
    Private m_Form As frmCalendar
    Private colCB As New Collection
    Private ctlCB As cCB
    
    Public Sub Init(ctl As CommandButton, frm As frmCalendar)
    Set m_CB = ctl
    Set m_Form = frm
    End Sub
    
    Private Sub m_CB_Click()
    m_Form.Info m_CB
    End Sub
    
    Private Sub Class_Terminate()
    Set m_CB = Nothing
    Set m_Form = Nothing
    End Sub
    so if i do have a indexing system and the collection of the class, what else do i need to fix it?

    As for the text. property instead of captions. property's there done , its a work in progress was editing until I get advice

    new copy uploaded

    Thanx for the help, its driving me mad and my blonde moments arent helpping, lol

    Attached Files Attached Files

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    all your textday controls are members of the colCB collection, but it is not indexed
    you can do like
    vb Code:
    1. Private Sub initfrmCalendar()
    2.  
    3.   Dim i As Integer    'Used as a counter
    4.   Dim iDay As Integer 'Used to set the day
    5.    
    6.   setStartIndex       'Set the starting index, first textbox to use
    7.   setEndIndex         'Set the ending index, last textbox to use
    8.   clearTextboxes      'Clear the calendar
    9.  
    10.   iDay = 1
    11.  
    12.   'Loop to fill the textboxes with days
    13.   'Also to re-enable the disabled ones
    14.   Dim caption As Control
    15.   For Each caption In frmCalendar.Controls
    16.  
    17.     If TypeOf caption Is CommandButton Then
    18.         caption.caption = iDay
    19.         caption.Enabled = True
    20.         caption.BackColor = vbWhite
    21.         iDay = iDay + 1
    22.     End If
    23.  
    24.   Next
    25.  
    26. ''  While iDay <= iEndIndex
    27. ''Dim txt
    28. ''Set txt = colCB(1).m_CB(1)
    29. ''txt.m_CB(1).caption = "Ohh"
    30. '' colCB.Item(iStartIndex).m_CB.caption = iDay
    31. '''Next
    32. '''    txtDay.caption = iDay
    33. ''    colCB(iStartIndex).Enabled = True 'Re-enable
    34. ''    colCB(iStartIndex).BackColor = vbWhite 'Reset the color
    35. ''
    36. ''    iDay = iDay + 1
    37. ''    iStartIndex = iStartIndex + 1
    38. ''
    39. ''
    40. ''  Wend
    41.  
    42.  
    43.   disableUnusedBoxes
    44.  
    45.  
    46. End Sub
    this still has some problems in as much as the close button gets a day value and the days are starting wrong

    it would habe been better if you command buttons were named like
    day1 .................... day42 (or similar)
    you could then use a loop like
    vb Code:
    1. for i = 1 to 42
    2.     me.controls("day" & i).caption = iday
    and know you are targeting a specific control in a known order
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Hi,
    Thanx,

    That’s got it passed the error now

    However how do I incorporate the setStartIndex and setEndIndex into that code above as they are tied in with alot of the code after passing this sub

    ta

  10. #10
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    i would try setting iDay backwards from the first of the month to if the 1st is tuesday start iday at -1
    vb Code:
    1. for i = 1 to 42
    2.           if iday > 0 and iday < endday then
    3.                me.controls("day" & i).caption = iday
    4.            else
    5.                 me.controls("day" & i).caption = ""
    6.           end if
    7.      next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Ta Pete

    I did that whilst waiting for a answer lol, but were or how to put the setStartIndex and setEndIndex is still a problem,

    Thanx

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    if iday is set to start correctly for the first day of the week, then istartindex is no longer required, or use it to set the value iday iday = 2 - istartindex
    the endday i used in the code sample is your setendindex, last day for that month
    vb Code:
    1. iday = 2 - istartindex
    2.       for i = 1 to 42
    3.                 if iday > 0 and iday < iendindex then
    4.                      me.controls("day" & i).caption = iday
    5.                  else
    6.                       me.controls("day" & i).caption = ""
    7.                 end if
    8.            next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Ok cool, yeap that seems to be working although its still not getting the year so it’s giving an error on setStartIndex(), as the year sets not being recognised.

    Also it cant get pass the code:-

    Code:
    Private Sub clearButtonboxes()
    
      Dim caption As Control
    
    'Set each cmd's value to ""
    
      For Each caption In frmCalendar
    
        If TypeOf caption Is CommandButton Then caption = ""
    
      Next
    
    End Sub
    
    Private Sub disableUnusedButtons()
    
      Dim caption As Control
    
      For Each caption In frmCalendar
    
        If TypeOf caption Is CommandButton Then
        
          If caption.caption = "" Then
            caption.Enabled = False
            caption.BackColor = &H8000000F
          End If
          
        End If
        
      Next
    
    End Sub
    and its giving the error "Object doesn't support this property or method" for the captions


    Thanx

  14. #14
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Re: Calendar Help

    Quote Originally Posted by helen85 View Post
    Also it cant get pass the code:-

    Code:
    Private Sub clearButtonboxes()
    
      Dim caption As Control
    
    'Set each cmd's value to ""
    
      For Each caption In frmCalendar
    
        If TypeOf caption Is CommandButton Then caption = ""
    
      Next
    
    End Sub
    You should refrain from using 'caption' as a variable name.
    Since you are using it to reference a command button, I don't believe the default property is the 'caption' property. Try:
    Code:
    If TypeOf caption Is CommandButton Then caption.caption = ""
    This also illustrates why you shouldn't use 'caption' as a variable name

    Plus, I believe you need to use
    For Each caption In frmCalendar.controls
    to reference the controls for the userForm

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    test, if the year has not been selected in the combo, use the current year

    or better set the year and month to current value in form activate
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Hi

    Yeap it has the year/month has been set on form activate

    Code:
    Private Sub Form_Activate()
    
      sSelectedMonth = "January" 'Default setting; need a value when the form is activated
      sSelectedYear = "2010"     'Default setting; need a value when the form is activated
      cboMonth.ListIndex = 0     'Go to first month
      cboYear.ListIndex = 0      'Go to first year
    End Sub

    Its also still erroring on Me.Controls("txtday" & i).caption = "", says it cant find the contorl.

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    do you have a txtday1?
    the original version did not, change txtday to txtday1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    yes I do have a txtday1

    the cmd's to from txtday1 to txtday42

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    yay fix it , its still getting the numbers in the worng order thou

  20. #20
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    post the updated version, i will have a look again
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    ok here is the updated one
    Attached Files Attached Files

  22. #22
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    i made some changes to your initfrmCalendar

    vb Code:
    1. Private Sub initfrmCalendar()
    2.  
    3.   Dim i As Integer    'Used as a counter
    4.   Dim iDay As Integer 'Used to set the day
    5.   Dim caption As Control
    6.  
    7.   setStartIndex       'Set the starting index,first textbox to use
    8.   setEndIndex         'Set the ending index, last textbox to use
    9.   clearButtonboxes    'Clear the calendar
    10.  
    11.   iDay = 1
    12.  
    13. 'Loop to fill the textboxes with days
    14. 'Also to re-enable the disabled ones
    15.  
    16.    iDay = 1 - iStartIndex
    17.   For i = 1 To 42
    18.     Me.Controls("txtday" & i).Visible = True
    19.     Me.Controls("txtday" & i).Enabled = True
    20.     Me.Controls("txtday" & i).BackColor = vbWhite
    21.     If iDay > 0 And iDay < iEndIndex + 1 Then
    22.       Me.Controls("txtday" & i).caption = iDay
    23.     Else
    24.       Me.Controls("txtday" & i).caption = ""
    25.       Me.Controls("txtday" & i).Visible = False
    26.     End If
    27.     iDay = iDay + 1
    28.   Next
    29. '   For Each caption In frmCalendar.Controls
    30. '   If TypeOf caption Is CommandButton Then
    31. ''        caption.caption = iDay
    32. ''       if not caption
    33. '        caption.Enabled = True
    34. '        caption.BackColor = vbWhite
    35. ''    iDay = iDay + 1
    36. '    End If
    37. 'Next
    38.  
    39.  
    40.  
    41.  
    42. '-------------------------------
    43.   'Dim i As Integer    'Used as a counter
    44.   'Dim iDay As Integer 'Used to set the day
    45.    
    46.  ' setStartIndex       'Set the starting index, first cmdbutton to use
    47.  ' setEndIndex         'Set the ending index, last cmbutton to use
    48.  ' clearButtonboxes      'Clear the calendar
    49.  
    50.  ' iDay = 1
    51.  
    52.   'Loop to fill the cmd's with days
    53.   'Also to re-enable the disabled ones
    54.  
    55.  ' While iDay <= iEndIndex
    56.  
    57.   '  txtDay(iStartIndex).caption = iDay
    58.    ' txtDay(iStartIndex).Enabled = True 'Re-enable
    59.     'txtDay(iStartIndex).BackColor = vbWhite 'Reset the color
    60.  
    61.     'iDay = iDay + 1
    62.     'iStartIndex = iStartIndex + 1
    63.    
    64.   'Wend
    65.  
    66. '  disableUnusedButtons
    67.  
    68. End Sub
    the calendar now appears to be correct, though some of the code maybe unneccessary
    Last edited by westconn1; Jan 3rd, 2010 at 03:53 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Ta,

    However the code given deletes the latter parts off the last month and the first part of the next month, any chance you could add this code bac.


    Thanx

  24. #24
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    i retested for every month in 2010 with correct result, if you mean that the commands with no day start and end are not shown i was under the impression (from the code) that was what you wanted, if not remove line 25, or change to enabled = false

    if this does not make sense, i do not understand what is not working correctly
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Thanx Pete

    Yep all the date are right,

    But want I would like it to do is for example if you were on the month Jan, then show the latter parts of Dec first and thefrist parts off Feb, instead of just blacking out the buttons, this was just to test that the maths was right

    Ta

  26. #26
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    try like this
    vb Code:
    1. bacol = vbWhite
    2.    iDay = 1 - iStartIndex
    3.   For i = 1 To 42
    4.     Me.Controls("txtday" & i).Visible = True
    5.     Me.Controls("txtday" & i).Enabled = True
    6.     Me.Controls("txtday" & i).BackColor = bacol
    7.    
    8.     If iDay > 0 Then
    9.       Me.Controls("txtday" & i).caption = iDay
    10.     Else
    11.       Me.Controls("txtday" & i).caption = Format(DateSerial(sSelectedYears, Month(SelectedMonth), iDay), "d")
    12.       Me.Controls("txtday" & i).BackColor = Me.BackColor
    13.     End If
    14.     iDay = iDay + 1
    15.     If iDay > iEndIndex Then iDay = 1: bacol = Me.BackColor
    16.  
    17.   Next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    what do I declear "bacol" as..

  28. #28

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    ok "type mismatch" for
    Code:
    Me.Controls("txtday" & i).caption = Format(DateSerial(sSelectedYear, Month(sSelectedMonth), iDay), "d")

  29. #29
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    dim bacol as long

    i am sure i had it working correctly this morning
    change to
    Me.Controls("txtday" & i).caption = Format(DateSerial(sSelectedYear, Month(1 & " " & sSelectedMonth & " " & sSelectedYear), iDay), "d")
    i could not figure a better way to return the month number from the month string, i am sure i am overlooking something simple

    this also works
    Me.Controls("txtday" & i).caption = Format(DateSerial(sSelectedYear, cboMonth.ListIndex + 1, iDay), "d")

    you do not really need some of the variables as they are always the value of the combo boxes

    i made some changes to your userform initalize to so the calendar will always start on the current month
    at the top
    ' cboMonth.Text = "January"
    ' cboYear.Text = "2010"
    ' sSelectedYear = cboYear.Text
    ' sSelectedMonth = cboMonth.Text

    at the end
    cboYear.Text = Year(Now)
    cboMonth.ListIndex = Month(Now) - 1
    Last edited by westconn1; Jan 8th, 2010 at 03:17 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  30. #30

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Thank you so much for your help, its now working perfectly

  31. #31

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    England
    Posts
    198

    Re: Calendar Help

    Hi I wonder if you can help me, as I have hit a brick wall again, one little adjustment should do it thought , the example code below (example1) is setting a date to a week number in this case “week1”, is then checking the date, etc to see if everything matches, if it does it the calls, “FindAllTHForWK2andWK6”

    “FindAllTHForWK2andWK6” searches a sheet picking up values and Offsetting cells to find more information, then and here is the problem,

    I am setting the correct information to the wrong button caption for example “txtDay2.caption”, when what I should be doing is checking to see if the label week2 is visible on the form and then loading the information into the right button underneath the label, using txtDay(i).caption


    The main function needed are below as examples they are also right at the top of the application code

    - WeekSetting
    - FindAllTHForWK2andWK6

    Code:
    Example1:
    'week1
            yr = cboYear  'set the year
            wkno = 43 ' starting week to find start date
            fday = Weekday(DateSerial(yr, 1, 1)) - 1 ' day of first day of year (month 1 day 1)
            j = (wkno - 1) * 7 + (2 - fday)  'calculate the starting day number for week no, can negative
            tmp = DateSerial(yr, 1, j)
            MsgBox "week " & wkno & " starts " & tmp
            
        If cboMonth.Text = "October" And cboYear.Text = "2010" Or cboMonth.Text = "October" And cboYear.Text = "2009" Or cboMonth.Text = "October" And cboYear.Text = "2011" Or cboMonth.Text = "October" And cboYear.Text = "2012" Or cboMonth.Text = "October" And cboYear.Text = "2013" Or cboMonth.Text = "October" And cboYear.Text = "2014" Or cboMonth.Text = "October" And cboYear.Text = "2015" Or cboMonth.Text = "October" And cboYear.Text = "2016" Or cboMonth.Text = "October" And cboYear.Text = "2017" Then
                     LblWeek2.Left = 108
                     LblWeek2.Top = 210
                     LblWeek2.Visible = True
                     LblWeek6.Visible = False
                     FindAllTHForWK2andWK6
    
    Example2
    Private Function FindAllTHForWK2andWK6()
       'Declare variables for tracking the entire range, the first found range, and the current found range.
        Dim currentFind As Excel.Range
        Dim sfirstFind As String
        
    'Search For Values - WEEK2 and WEEK6 + ALL TH's
        
    If CboTH.Text = "Theatre 2" Then
        '----------TH2------------
        Dim Theatre2Week2and6  As Excel.Range
        Set Theatre2Week2and6 = Range("A20", "I36") 'Week set by ranges as only wk1 and wk5 have rough range values off A4-I16
    
        ' Search for the first match, specifying all the parameters except the cell to search after.
        ' specify all these parameters every time you call this method,
        ' NB: they can be overridden in the user interface.
        Set currentFind = Theatre2Week2and6.Find("Theatre 2", , Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, False)
        
        If Not currentFind Is Nothing Then
            ' Keep track of the first range you find.
            sfirstFind = currentFind.Address
            'Continue searching as long as there are matches.
           
            Do
                MsgBox "Found Theatre 2 at: " & currentFind.Text
                'Perform another search
                 Set currentFind = Theatre2Week2and6.FindNext(currentFind)
            Loop While Not currentFind Is Nothing And currentFind.Address <> sfirstFind
            
            End If
            
             Dim InfoRange As Excel.Range
             Dim WkDayRange As Excel.Range
              
            ' CASE: the weekday vaules
    
    '--------- MONDAY VALUES
            ' Find the 1st information range for the TH to be selected
                currentFind.Offset(1, 0).Select ' move 1 cell down
            ' Find the 2nd information range for the TH to be selected
                currentFind.Offset(2, 0).Select ' move 2 cell down
            ' Find the 1st cell for that Weekday and Session as ref to the calendar
                currentFind.Offset(1, -1).Select ' move 1 cell left and down
             ' Find the 2nd cell for that Weekday and Session as ref to the calendar
                currentFind.Offset(2, -1).Select ' move 2 cell left and down
                    'Format the string
    
           txtDay9.caption = Trim(txtDay2.caption)
     
     ' load text found to captions
     txtDay9.caption = currentFind.Offset(1, -1) & "= " & currentFind.Offset(1, 0) & vbCrLf & currentFind.Offset(2, -1) & "= " & currentFind.Offset(2, 0)
                                                        '(1,0)(2,0)(1,-1)(2,-1)
       'format text captions  - NEEDS WORK
             'ToDo: Trim
     
     txtDay9.caption = Replace(txtDay9.caption, "MONDAY", "")
     txtDay9.caption = Trim(txtDay9.caption)
    Your help is greatly appreciated

    Attached Files Attached Files

  32. #32
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Calendar Help

    it would be nice if you checked that sample workbooks actually work when you post them

    i still do not understand what result you want to get on your calendar
    the search string in your code (Theatre 2) is never found
    your call procedures that have incorrect names or do not exist
    how do you know which label you want to show?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width