+ Reply to Thread
Results 1 to 8 of 8

User Form field inserts wrong date format

Hybrid View

  1. #1
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: User Form field inserts wrong date format

    If the date is in format dd/mm/yyyy you can try to use this code (here I suppose your data field in form is called 'Textbox1'):
    Private Sub Macro1()
       Dim myDate As Date
       myDate = DateSerial(Mid(TextBox1.Text, 7, 4), _
                           Mid(TextBox1.Text, 4, 2), _
                           Mid(TextBox1.Text, 1, 2))
       Range("A1") = myDate
    End Sub
    Regards,
    Antonio

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: User Form field inserts wrong date format

    The date problem is something users who do not use the American date format have been having to deal with for years


    See my reply in this old thread

    http://www.excelforum.com/excel-prog...and-forms.html

    There is also a little bit more in this thread

    http://www.excelforum.com/excel-prog...-workbook.html
    Last edited by shub; 05-15-2014 at 06:11 AM.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor
    Join Date
    07-31-2008
    Location
    Berkshire, UK
    MS-Off Ver
    2003 & 2007
    Posts
    118

    Re: User Form field inserts wrong date format

    Thank you for all your suggestions.

    Here is a copy of the sheet I am using.

    On the Feedback Summary sheet, if you click on the top button, a form appears. The feedback is recorded and then summarised on the other sheet.

    The trouble is, I am now trying to work out how to summarise each category for each trainer PER MONTH so when the date goes in, incorrectly it's not gerating the correct date.

    Mudraker, I couldn't see those hyperlinks but I will have a search.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: User Form field inserts wrong date format

    Hi again,

    The highlighted addition to your code seems to give the correct result on my system (Excel 2000):

    Private Sub cmdOK_Click()
        ActiveWorkbook.Sheets("Feedback Summary").Activate
        Range("A1").Select
        Do
        If IsEmpty(ActiveCell) = False Then
            ActiveCell.Offset(1, 0).Select
        End If
        Loop Until IsEmpty(ActiveCell) = True
        ActiveCell.Value = DateValue(txtDate.Value)
        ActiveCell.Offset(0, 1) = cboCourse.Value
        ActiveCell.Offset(0, 2) = cboTrainer.Value
        ActiveCell.Offset(0, 3) = cboDels.Value
        ActiveCell.Offset(0, 4) = txtCat1.Value
        ActiveCell.Offset(0, 5) = txtCat2.Value
        ActiveCell.Offset(0, 6) = txtCat3.Value
        ActiveCell.Offset(0, 7) = txtCat4.Value
        ActiveCell.Offset(0, 8) = txtCat5.Value
        ActiveCell.Offset(0, 9) = txtCat6.Value
        ActiveCell.Offset(0, 10) = txtComm.Value
        Range("A1").Select
    End Sub
    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

+ 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