98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Date in a text field copied wrongly into destination file (month
Date in a text field copied wrongly into destination file (month
Resolved · Medium Priority · Version 2010
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
Mon 27 Jul 2015: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Using the Quick Access Toolbar in Excel2010The Quick Access Toolbar is included in virtually every Office product, including Outlook 2010, Word 2010, Excel 2010, and PowerPoint 2010. |