PDA

View Full Version : Solved: Date from textbox to cell



sujittalukde
04-17-2008, 06:31 AM
I am using the follwing code to transfer date from textbox on a user form to a cell:
ActiveCell.Offset(0, 2).Value = Format(CDate(TextBox2.Value), "dd/mm/yyyy")
But the date is transferred as "mm/dd/yyyy" format.
My regional setting etc is in dd/mm/yyyy format. Also if I directly enter date in the cell, the date is saving well in dd/mm/yyyy format.
What to do now to fix this problem?

mikerickson
04-17-2008, 06:37 AM
Since the cell is formatted the way that you want it, the cell needs to be filled with the underlying value rather than the formatted value.

ActiveCell.Offset(0, 2).Value = CDate(TextBox2.Value)

sujittalukde
04-17-2008, 06:44 AM
Thanks its working great now.