• VBA Date Picker problem

    Author
    Topic
    #462348

    Hi,

    I created a user form with a Microsoft Date Picker control. My problem is that when I run the form and select a date from the picker control, it returns a time to the spreadsheet. I cannot seem to get it to transfer the date into the cell? What am I missing???

    Here is my tester code…

    Private Sub CommandButton1_Click()
    Unload Me
    Range(“A1”).Value = Me.DTPicker1.Value
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #1176454

      SOLVED!!!

      One should not unload the form before you collect the value of the date picker.

      This fixes it !! (So simple – )
      Private Sub CommandButton1_Click()
      Range(“A1”).Value = Me.DTPicker1.Value
      Unload Me
      End Sub

      • #1177622

        Yep – “Unload” means “remove from memory”, so after that action, the value of a control on the userform is not valid any more.

    Viewing 0 reply threads
    Reply To: VBA Date Picker problem

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: