+ Reply to Thread
Results 1 to 11 of 11

date format in VBA user form

  1. #1
    Registered User
    Join Date
    12-12-2008
    Location
    UK
    Posts
    4

    date format in VBA user form

    Problem solved! Thanks to all responses. Appreciated.

    I have created a user form with a date field which fills a spreadsheet cell. The spreadsheet cell is formatted to dd/mm/yy but the user form will always enter as mm/dd/yy. Does anyone know how to edit the VBA form to use the dd/mm/yy format please. This is my first post so apologies if description of problem is obscure.
    Last edited by TerryWingfield; 12-16-2008 at 06:50 AM. Reason: SOLVED

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482
    Try These
    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You will need to make sure that you change the textbox name & destination cell
    Please Login or Register  to view this content.
    You might be interested in this
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    12-12-2008
    Location
    UK
    Posts
    4
    Quote Originally Posted by davesexcel View Post
    Try These
    Please Login or Register  to view this content.
    Hello Dave

    I have tried your code (reproduced below)

    Private Sub txtBookingdate_Change()
    txtBookingdate = Format(txtBookingdate, "dd/mm/yy")

    End Sub

    but find it returns the date 30/12/1899 plus the first digit I enter. What am I doing wrong? txtBookingdate is the name of the text box in my UserForm.

    Thanks for your speedy response on Friday.

    Terry Wingfield

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302
    The Change event will fire for each keystroke you make. Try using the AfterUpdate or Exit events instead.

  6. #6
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    is this what you are after???


    Please Login or Register  to view this content.
    on Userform Initialize
    I dont like to use code i dont understand
    it makes it hard to use in other situations
    so please try to be as clear and patent as possible with me

    Criticism is welcomed

  7. #7
    Registered User
    Join Date
    12-12-2008
    Location
    UK
    Posts
    4
    That helps thanks. My original problem which has not been solved, however, is that the date format I want in my spreadsheet is dd/mm/yy and is formatted as such but when I enter that format in the User Form it enters mm/dd/yy in the spreadsheet. Any thoughts?

  8. #8
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    couldnt you just insert the value of "textbox1" into the req'd cell?

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302
    If you are transferring the date via code, use CDate (assuming your system is set to UK format):
    Please Login or Register  to view this content.
    for example.

  10. #10
    Registered User
    Join Date
    12-12-2008
    Location
    UK
    Posts
    4
    Thanks Friel

    That's done the trick

    regards
    Terry

  11. #11
    Forum Contributor FRIEL's Avatar
    Join Date
    03-07-2008
    Location
    Coventry
    MS-Off Ver
    2003 and 2007
    Posts
    266
    no problem
    glad to help

+ 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