Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2003
    Dallas, Texas, USA
    Thanked 0 Times in 0 Posts

    date field from UserForm doesn't paste correctly (ExcelXP)

    I have a UserForm that I have created to allow someone to input inventory information - the form then deposits that information into the correct cells in an Excel worksheet. The problem is this: the date field on the Userform was created as a TextBox - so when it pastes the date into the worksheet, the format is as a "text date" with a 2 digit year. I would like to be able to format this as a date format - with a 4 digit year, but I can't seem to figure out how to code that. Is my problem that the field was created as a text box? What other option would I have? Please someone help me! Thanks!!!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: date field from UserForm doesn't paste correctly (ExcelXP)

    If you have set the ControlSource property of the text box to the appropriate cell, the only thing you have to do is to set the number format of that cell to the desired date format.

    If you haven't set the ControlSource property, and fill the cell in code, use something like

    Range("A1") = DateValue(Me.TextBox1)

    and again, set the number format of the target cell (A1 in this example) to the desired date format.

Posting Permissions

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