Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

date text field copied

Forum 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

ResolvedVersion 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

RE: Date in a text field copied wrongly into destination file (m

Hi Jens,

sorry for the delay in checking it!

I have tried what you suggested and it does not work either.

Kind regards,
Susanna

Mon 27 Jul 2015: Automatically marked as resolved.

 

Training courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Wrapping Text in a Cell in an Excel 2010 Workbook

When you have a lot of text you want to put in a particular cell but you can't decrease the font size to fit because the text will then become ineligible, then manually wrap the text in a cell by simply pressing ALT+ENTER.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.