ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform and passing date values (https://www.excelbanter.com/excel-programming/272394-userform-passing-date-values.html)

DTM

Userform and passing date values
 
Hi all,
Hey I have a userform in which I want the user to enter a
date in a field (NZ dd/mm/yy). First of all is there
anyway to format the text box to be a date format?
but more importantly - when the value is passed to the
cell I want to put it in - if the date is for example
05/04/03 (5th April 03) on the form - it enters the value
04/05/03 (4th May 03) no matter how I format the cell or
the date to use the NZ format of day/month/year it comes
back month/day/year.

This only happens when the day/months could be reversible.
IE if I enter 23/6/03 it treats it like I want it to
dd/mm/yy.

the code I'm using to pass the variable to the cell is:

NextRow = Application.WorksheetFunction.CountA(Range
("D:D")) + 5
etc etc
Cells(NextRow, 3) = Referral_date.Text

thanks for any help
dean


Tom Ogilvy

Userform and passing date values
 
Can't format a textbox.

Cells(NextRow, 3) = cDate(Referral_date.Text)

Might help.

Regards,
Tom Ogilvy


DTM wrote in message
...
Hi all,
Hey I have a userform in which I want the user to enter a
date in a field (NZ dd/mm/yy). First of all is there
anyway to format the text box to be a date format?
but more importantly - when the value is passed to the
cell I want to put it in - if the date is for example
05/04/03 (5th April 03) on the form - it enters the value
04/05/03 (4th May 03) no matter how I format the cell or
the date to use the NZ format of day/month/year it comes
back month/day/year.

This only happens when the day/months could be reversible.
IE if I enter 23/6/03 it treats it like I want it to
dd/mm/yy.

the code I'm using to pass the variable to the cell is:

NextRow = Application.WorksheetFunction.CountA(Range
("D:D")) + 5
etc etc
Cells(NextRow, 3) = Referral_date.Text

thanks for any help
dean




No Name

Userform and passing date values
 
Thanks Tom,
that works


-----Original Message-----
Can't format a textbox.

Cells(NextRow, 3) = cDate(Referral_date.Text)

Might help.

Regards,
Tom Ogilvy





All times are GMT +1. The time now is 02:37 PM.

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