+ Reply to Thread
Results 1 to 13 of 13

Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

  1. #1
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Unhappy Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Hello Friends, i am trying to modify the below code i got somewhere from the web, it works fine but i need it to update date in cell in "dd/mm/yyyy" or "dd/mm/yy" format ...here is my code .........

    Private Sub txtDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    If Len(Me.txtDate.Value) = 8 Then
    txtDate.Value = Format(txtDate.Value, "00/00/0000")
    ElseIf Len(Me.txtDate.Value) = 6 Then
    txtDate.Value = Format(txtDate.Value, "00/00/00")
    End If

    End Sub

    Waiting for your valuabe suggestion..........

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    That code doesn't update any cells. Is your textbox linked directly to a cell?
    Rory

  3. #3
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Thanks for your kind response, actually i am updating value through user form in which one field is date field it paste directly to disire cell but in mm/dd/yyyy format i want it to save in dd/mm/yyyy format

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    You didn't answer my question. Is the textbox linked directly to the cell, or are you using code to update the cell?

  5. #5
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    I am using code to update the cell

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Then you should wrap the textbox value in the CDate function when you assign it to the cell to convert it to a real date value using your regional settings rather than VBA's US formats.

  7. #7
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Quote Originally Posted by rorya View Post
    Then you should wrap the textbox value in the CDate function when you assign it to the cell to convert it to a real date value using your regional settings rather than VBA's US formats.
    Could you give an assistant on a vba code i can send you my excel file..

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    I don't need the file, I just need the line of code that populates the cell.

  9. #9
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    .Cells(irow, 2) = RECEIPT.txtDate.Value

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Change that to:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-15-2020
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    6

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Thank you so much for your support it works fine, but it storing data in mm-dd-yyy format how to change it to mm-dd-yyyy format

  12. #12
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    try
    Please Login or Register  to view this content.

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Update Date Field From User Form in dd/mm/yyyy format instead of mm/dd/yyyy format

    Change the number format of the cell:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 04-25-2019, 11:05 AM
  2. Convert Date format from Text format reading m/d/yyyy to dd/mm/yyyy
    By bridge4444 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-23-2017, 11:22 PM
  3. User Form changes date from dd/mm/yyyy to mm/dd/yyyy On Spreadsheet
    By JamesJohnson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2014, 06:08 AM
  4. Replies: 7
    Last Post: 11-18-2012, 02:28 PM
  5. [SOLVED] Date format of yyyy-mm-dd for field entry in user form
    By ajolin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2012, 02:22 AM
  6. [SOLVED] Imported data contains strings dd.mm.yyyy how can I convert to date format dd/mm/yyyy inVB
    By Boormo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2012, 05:48 PM
  7. [SOLVED] opening excel file -> date format problem: DD/MM/YYYY vs MM/DD/YYYY
    By yung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2005, 09:06 AM

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