PDA

View Full Version : Format of date in text box differs from the corresponding cell.



christoday
02-04-2007, 03:05 PM
I've created a userfrom to retrieve data from a spreadsheet and save it back as appropriate. Data from specific cells is poulated into the corresponding text box. I have received some excellent assistance from Charlize on the search and save functions.

The problem I've been trying to solve for the last few days is a date formatting anomaly. Where the date in the cell is in the format dd/mm/yyyy, the form retreives this and reformats it to mm/dd/yyyy.

I've received some assistance with this but I'm finding it very hard to code the solution into the form. Any ideas/help?

The majority of cells are dates but one example in my form is TxtLetter and this corresponds to (0, 6)

I've attached, thanks.

mdmackillop
02-04-2007, 03:10 PM
You could try
TextBox1.Text = Format(Range("A1"), "dd/mm/yy")

Bob Phillips
02-04-2007, 03:15 PM
TxtLetter.Text = Worksheets("Sheet1").Range("A1").Text

One thing to be aware of is that VBA is very US-centric with regards to dates, always best to store in a date variable, or cast to a date (CDate).