Consulting

Results 1 to 3 of 3

Thread: Solved: Calendar Control 11 - Open on today

  1. #1

    Solved: Calendar Control 11 - Open on today

    Hi Guys

    I must admit that I'm asking out of sheer annoyance. I know there are hundreds of references to calendar control on the web and I've looked through them and those on this forum, but none seem to be providing a solution.

    I've got a calendar control embedded into a worksheet that I simply want to default to todays date when the workbook opens, however, this is proving to be extremely difficult. There are loads of available solutions if I make this into a userform, but I really would rather that this stayed as an object on the worksheet itself.

    So far, I've got:

    [vba]'automatically set the date to todays date on opening the workbook

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveCell = Sheets("console").Range("A1")
    ActiveCell.Value = Date

    If IsDate(ActiveCell.Value) Then
    Calendar1.Value = ActiveCell.Value
    Else
    Calendar1.Value = Date
    End If

    Sheets("console").Range("A1").ClearContents


    End Sub[/vba]

    This worked when I first wrote it, but now it seems to be being obnoxious and refuses to work.

    Any ideas?

    Thanks

    Phel

    EDIT - I'm working in 2003....don't ask...

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,873
    Quote Originally Posted by Phelony
    calendar control embedded into a worksheet that I simply want to default to todays date when the workbook opens
    In the ThisWorkbook code module:
    [vba]Private Sub Workbook_Open()
    Sheets("NameOfSheetTheCalendarControIsOn").Calendar1.Value = Date
    End Sub
    [/vba]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    That's annoyingly obvious...darn...

    Thank you so much, couldn't see the wood for the trees there!



    Phel

Posting Permissions

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