Results 1 to 2 of 2

Thread: Userform date formats (US to UK)

  1. #1
    Acolyte thousand's Avatar
    Join Date
    Apr 2017
    Posts
    25
    Articles
    0
    Excel Version
    2010

    Userform date formats (US to UK)



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi, I currently have these codes which adds data from userform into a worksheet. The dates appear in US form, is there a way to format this? Have tried cdate but doesn't work.

    Thanks

    Code:
    Sub ToggleButton1_Click()
    'Find the last Row with data in a Column
        Dim NextRw As Long
        With ActiveSheet
            NextRw = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
            
        End With
        
    'Add data from userform
    Cells(NextRw, 1) = ComboBox1.Text
    Cells(NextRw, 2) = ComboBox2.Text
    Cells(NextRw, 3) = TextBox1.Text
    Cells(NextRw, 4) = TextBox2.Text
    Cells(NextRw, 5) = TextBox3.Text
    Cells(NextRw, 6) = TextBox4.Text
    Cells(NextRw, 7) = TextBox5.Text
    Cells(NextRw, 8) = ComboBox3.Text
    Unload Me
    End Sub
    Last edited by AliGW; 2019-07-02 at 08:13 AM. Reason: Code tags added

  2. #2
    Neophyte Knoet's Avatar
    Join Date
    May 2019
    Posts
    4
    Articles
    0
    Excel Version
    2016
    Hi,
    try these.
    Assume date textbox is TextBox1.
    Code goes in the Private Sub UserForm_Initialize() event.
    Code:
    TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy")
    or
    Code:
    TextBox1.Value = Format(Date, "dd/mm/yyyy")
    or in the Sub ToggleButton1_Click() event.
    Code:
    Cells(NextRw, 3) = CDate(TextBox1.Value)

Tags for this Thread

Posting Permissions

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