Range Data formating texttocolumns

ronitbell

New Member
Joined
May 16, 2019
Messages
1
Hello, I am trying to run texttocolumns using VBA

Range("O4:O1500").Selection.TextToColumns _
Destination:=Range("O78"), _
DataType:=False, _
ConsecutiveDelimiter:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False, _
FieldInfo:=Array(1, 4)

I would need this range to have the format date as " 25/1/2019" but can not change it by VBA, only on the excell sheet menu.
Data stays in the format : Februar 2019 4

Any idea?
Thank
Ronit
 

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
548
I'm not sure this is the solution, but I've noticed that often the Locale setting for the Date format often get's mysteriously moved to a different country, which will give me a messed up date format.

Alternatively, the FieldInfo array should output a DMY format (#4) (https://docs.microsoft.com/en-us/office/vba/api/excel.xlcolumndatatype); not sure why it's actually outputting MYD (Array(1, 6)). Actually, I'm not understanding the output; month and year I get, but how did it come up with 4 for the day from 25/1/2019?? Or, is that a typo?
 
Last edited:

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
548
Actually, a little trial showed that if I chose the TtoC date format that the date is actually in (25/1/2019 = DMY), then the output was into whatever my system default is or you can change the format to whatever you like.

So, whatever format the original data is in, choose that date format in the TtoC code/wizard.
 

Forum statistics

Threads
1,085,879
Messages
5,386,521
Members
402,003
Latest member
johnpearson67

Some videos you may like

This Week's Hot Topics

Top