Date formatting issue

CookieMonster76

Board Regular
Joined
Apr 30, 2015
Messages
195
Hi

I have a text file that comes out of a finance system, that needs converting into excel.

It has a series of dates. I have recorded a macro, and the result comes out as I would expect whilst recording, but when I re-run it as a macro, it is changing the format i.e. (English date format) 04/10/22 is changing to 10/04/22.

The odd thing is that it is only doing it one some lines, the vast majority are correct.

The relevant part of the code is:

DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(11, 1), Array(21, 1), Array(22, 1)

Does anyone have a suggestion as to why, and how I can fix it?

Thanks
Paul
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
VBA Code:
Sub Maybe()
Dim c As Range
For Each c In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(2)
c.Offset(, 2).Value = "'" & Format(c, "MM.DD.YYYY")
Next c
End Sub
 
Upvote 0
I have shut down for the night, but in your original code, does it let you add ", Local:=True" (without quotes but including the comma) at the end of the line ?
 
Upvote 0
I don't understand your message, did you try
VBA Code:
DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(11, 1), Array(21, 1), Array(22, 1)),Local:=True
 
Upvote 0
Solution
I don't understand your message, did you try
VBA Code:
DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(11, 1), Array(21, 1), Array(22, 1)),Local:=True
No, I did not. Im not owner of question tho.
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,034
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top