+ Reply to Thread
Results 1 to 4 of 4

Calendar Control

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    28

    Calendar Control

    I don't think I am understanding how VBA handles the passing of objects and stuff when a button is pressed.

    Basically, I have a calender control with the name calendar1 and when I press the command button I want to put the date into a cell. So the code I have so far:

    Please Login or Register  to view this content.
    But I get the Compile error:

    Procedure declaration does not match description of event or procedure having the same name.

    Can someone explain how VBA handles the sending of objects into subs?

  2. #2
    Nick Hodge
    Guest

    Re: Calendar Control

    FCC

    I would not use a button at all. If the calendar control is on the
    worksheet, paste code like this into the calendar control click event (right
    click on the calendar and select view code)

    Private Sub Calendar1_Click()
    Me.Range("A1").Value = Calendar1.Value
    End Sub

    It places the date selected in the calendar in A1 of the sheet each time it
    is clicked

    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    www.nickhodge.co.uk
    [email protected]HIS


    "FCC" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I don't think I am understanding how VBA handles the passing of objects
    > and stuff when a button is pressed.
    >
    > Basically, I have a calender control with the name calendar1 and when I
    > press the command button I want to put the date into a cell. So the
    > code I have so far:
    >
    >
    > Code:
    > --------------------
    >
    > Private Sub CommandButton1_Click(Calendar1 As Object)
    > Range("A1") = Calendar1.Value
    >
    > End Sub
    >
    > --------------------
    >
    >
    > But I get the Compile error:
    >
    > Procedure declaration does not match description of event or procedure
    > having the same name.
    >
    > Can someone explain how VBA handles the sending of objects into subs?
    >
    >
    > --
    > FCC
    > ------------------------------------------------------------------------
    > FCC's Profile:
    > http://www.excelforum.com/member.php...o&userid=35888
    > View this thread: http://www.excelforum.com/showthread...hreadid=557644
    >




  3. #3
    Registered User
    Join Date
    06-29-2006
    Posts
    28
    Well actually, the calender is part of a user form which the user uses to enter an employee's name and their employment date.

    Which is why I would like a command button to handle both the username and the employment date at the same time.

  4. #4
    Nick Hodge
    Guest

    Re: Calendar Control

    In which case the button should hide the userform and then you can place the
    data in the worksheet and unload the form from memory (Me refers to the
    container...form, that contains the control)

    Private Sub CommandButton1_Click()
    Me.Hide
    Worksheets("Sheet1").Range("A1").Value = Calendar1.Value
    Unload Me
    End Sub

    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    www.nickhodge.co.uk
    [email protected]HIS


    "FCC" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Well actually, the calender is part of a user form which the user uses
    > to enter an employee's name and their employment date.
    >
    > Which is why I would like a command button to handle both the username
    > and the employment date at the same time.
    >
    >
    > --
    > FCC
    > ------------------------------------------------------------------------
    > FCC's Profile:
    > http://www.excelforum.com/member.php...o&userid=35888
    > View this thread: http://www.excelforum.com/showthread...hreadid=557644
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1