Results 1 to 4 of 4

Thread: Calendar Control help

  1. #1

    Calendar Control help



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi All

    I'm completely new to VBA and just need guidance on what I'm doing wrong....

    I have a very simple spreadsheet called general to which I want to add a calendar control designed completely using vba coding to it.

    However when I simply pull the object, form and module across to my spreadsheet i encounter all kinds of issues/compile errors/missing library/components etc....and I'm not sure how to get the code across properly...

    I have also attached a second version where I seem to have pulled the code across, however the calendar doesn't work!

    What I would like it to do is activate the calendar control when I click in cell A2:A5000, choose the date and then have it insert it into the cell I selected in the above range.

    The calendar control has been designed by someone else and looking through various posts in other forums it seems to work fine....so it must be me and my lack of skills....

    Thanks for any help...
    Attached Files Attached Files

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    Can you provide a link to the other forums where you see the code working correctly? It may help us diagnose the issues.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    You have to change the selection change event like so:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        'The 1st method is coded to launch when a curtain cell is  selected
        If Not Intersect(Target, Range("A2:A5000")) Is Nothing Then
            CalendarFrm.Show
        End If
        'another method is to have it show if a cell that is formatted as a date is selected...see below
        If Target.NumberFormat = "m/d/yy;@" Then
            CalendarFrm.Show
        End If
        'another method is using Select Case...see below
        Select Case Target.NumberFormat
            Case Is = "m/d/yy", "m/d/yyyy", "m/d/yy", "mm/dd/yy", "yyyy-mmm-dd"
            CalendarFrm.Show
            'Case Else
            '    MsgBox "Not a valid date format!"
        End Select
    End Sub
    Regards,
    Jan Karel Pieterse
    www.jkp-ads.com

  4. #4
    Neophyte psawyer's Avatar
    Join Date
    Feb 2012
    Location
    Berlin, Germany
    Posts
    3
    Articles
    0

    Alternative to calendar control

    Here an alternative to calendar control.
    Attached Files Attached Files

Posting Permissions

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