Consulting

Results 1 to 5 of 5

Thread: Solved: Date Format in UserForm

  1. #1

    Solved: Date Format in UserForm

    Hi all

    I'm using a userform to update existing cells in worksheet.
    i have a date textbox and need formatting to apply to it.

    Don't know if my question makes sense but here goes:
    how do i change the code
    Range("A1").NumberFormat = "dd/mm/yyyy"

    to work on a textbox called DateContact
    something like
    Me.DateContact.NumberFormat = "dd/mm/yyyy"

    obviously NumberFormat cannot be used with Me.DateContact as it only works when referring to a Range

    Newbie

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    DateContact.Text = Format(DateContact.Text, "dd/mm/yyyy")
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thank you very much, xld code works now
    i still have a bit of stability issues to sort because it sometimes saves as mm/dd/yyyy although the format is now set however if i close the form and open again it shows correctly as dd/mm/yyyy
    But it doesn't happen like that every time

    Thanks for the assistance

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this amendment

    [vba]

    DateContact.Text = Format(CDate(DateContact.Text), "dd/mm/yyyy")
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    That works better, thank you

Posting Permissions

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