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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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:
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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