ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Format in Userform (https://www.excelbanter.com/excel-programming/363675-date-format-userform.html)

Peter1999

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


--
Peter1999
------------------------------------------------------------------------
Peter1999's Profile: http://www.excelforum.com/member.php...o&userid=33997
View this thread: http://www.excelforum.com/showthread...hreadid=549886


[email protected]

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



Peter1999[_2_]

Date Format in Userform
 

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


[email protected]

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



(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




All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com