+ Reply to Thread
Results 1 to 4 of 4

Date Format in Userform

  1. #1
    Registered User
    Join Date
    04-30-2006
    Posts
    55

    Date Format in Userform

    Hi,

    I'm looking for a code to transform a number value in a userform to a date value after enter is pressed. For example, in the UF, the user would enter 010100, which would change to the date format 01-Jan-2000 after enter (or tab) is pressed or another cell selected. Any ideas? Thanks in advance,

    Peter

  2. #2

    Re: Date Format in Userform

    as long as you can legislate that they type it correctly (!)

    use the exit event of the textbox (for this example called TxtDate)

    txtDate.text=Format(DateSerial(Right(TxtDate, 2), Mid(txtDate, 3, 2),
    Left(txtDate, 2)), "dd-mmm-yyyy")


    (note I'm in the UK so have taken your date as DDMMYY - change the date
    serial around as necessary)
    Peter1999 wrote:
    > Hi,
    >
    > I'm looking for a code to transform a number value in a userform to a
    > date value after enter is pressed. For example, in the UF, the user
    > would enter 010100, which would change to the date format 01-Jan-2000
    > after enter (or tab) is pressed or another cell selected. Any ideas?
    > Thanks in advance,
    >
    > Peter
    >
    >
    > --
    > Peter1999
    > ------------------------------------------------------------------------
    > Peter1999's Profile: http://www.excelforum.com/member.php...o&userid=33997
    > View this thread: http://www.excelforum.com/showthread...hreadid=549886



  3. #3
    Registered User
    Join Date
    04-30-2006
    Posts
    55
    Thanks for replying!
    However, no matter what I do, VB returns the message that it's a mismatch...
    I'm just a newbie at VB so any additional help would be appreciated ;-)

    Thanks again,

    Peter

  4. #4

    Re: Date Format in Userform

    As I tested it first, I know it works - but maybe you haven't swapped
    the date around as I suggested - 010100 is not a good example as I
    don't know if the first 01 is January or the day!

    IF you need help with the debugging, you can email me at

    aidan.heritage_Pink_meat_@_pink_meat_virgin.net

    (remove all _pink_meat_ from the email address for it to work!)

    Peter1999 wrote:
    > Thanks for replying!
    > However, no matter what I do, VB returns the message that it's a
    > mismatch...
    > I'm just a newbie at VB so any additional help would be appreciated
    > ;-)
    >
    > Thanks again,
    >
    > Peter
    >
    >
    > --
    > Peter1999
    > ------------------------------------------------------------------------
    > Peter1999's Profile: http://www.excelforum.com/member.php...o&userid=33997
    > View this thread: http://www.excelforum.com/showthread...hreadid=549886



+ 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