Susanna has attended:
Excel VBA Intro Intermediate course
Taking Minutes course
Excel VBA Advanced course
Excel PowerPivot course
Date in a text field copied wrongly into destination file (month
I have dates in an array, to be moved to destination file. These dates are characters, and when I move them to final file, the month becomes the day and the day becomes the month, that is:
"01/07/2015" goes into the final file as
07/01/2015
I've tried various things, being the last one Dateserial funtion, but I still get the wrong data:
Dim vConvDate As Date
vConvDate = DateSerial(Val(Year(vWorkTable(i, Val(j)))), Val(Month(vWorkTable(i, Val(j)))), Val(Day(vWorkTable(i, Val(j)))))
Cells(vIndex, vColDB) = vConvDate
Can you please tell me what is the problem?
Thank you very much
RE: Date in a text field copied wrongly into destination file (m
Hi Susanna,
Thank you for the forum question.
Yes date formats can be a complicated thing to get right in Excel. I have had many questions about date formatting.
Many times when we import data from external data source we have the problem also sometimes when it is internal data.
Can I ask you to try the code below where the only thing you need to amend is the range. In my code I reformat column A.
Sub dateformat()
Dim c As Range
For Each c In ActiveSheet.UsedRange.Columns("a").Cells
c.Value = DateValue(c.Value)
Next c
End Sub
If it is not doing the job please let me know.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector