• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

TextToColumns date format is changing after split|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / TextToColumns date format is changing after split|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosTextToColumns date format is changi…
sp_PrintTopic sp_TopicIcon
TextToColumns date format is changing after split
Avatar
Sebastian Fuentes

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
April 8, 2021
sp_UserOfflineSmall Offline
1
May 16, 2021 - 3:49 am
sp_Permalink sp_Print

Hello All,

I have a ".CSV" File (Exportación de datos - Movimiento facturas de venta - 2021-05-15T180919.705), which is dowloaded from a web ERP. A second File ".xlsm"  ("Movimiento_venta_2020_V4.xlsm") is used to run a couple of macros (scrap data, consolidating, extracting......). However, one of these macros opens the ".CSV" File, split the data (TextToColumns), with the aim to copy it on the ".xlsm" File. The ISSUE is caused once the code "TextToColumns " is used to split the data, changing the format of SOME of the cells from "dd/mm/yy" to "mm/dd/yyyy". See enclosed the picture "TextoColumn_Before-After.JPG".

I have used several parameters of the TextToColumns functions but I have not succeeded.

Note: in the case is relevant -> The ERP use Spanish Language and my Excel is in English Language

------------------------------------------

Location of the Macro: 

File: "Movimiento_venta_2020_V4.xlsm" (size is to big to attached)

Module: Web

Sub:  OpenLatestFile()

code currently used: Range("A:A").TextToColumns , DataType:=xlDelimited, Semicolon:=True

Other Code attempts:

'Range("A:A").TextToColumns , DataType:=xlDelimited, Semicolon:=True, TextQualifier:=xlDoubleQuote, _
' FieldInfo _
' :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, xlDMYFormat), _
' Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
' ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
' (20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _
' Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array( _
' 33, 1), Array(34, 1), Array(35, 1)), TrailingMinusNumbers:=True

-----------------------------------------------

The ".CSV" File (Exportación de datos - Movimiento facturas de venta - 2021-05-15T180919.705) enclosed was cutted in size to be able  to attached it here.

---------------------------------------------------

Thanks in advance

TextoColumn_Before-After.JPGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage TextoColumn_Before-After.JPG (101 KB)
sp_AnswersTopicSeeAnswer See Answer
Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1824
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
May 18, 2021 - 3:52 pm
sp_Permalink sp_Print

Why not using Power Query to import csv data?

It's much more powerful than TextToColumns.

To make the current code work, you have to change your regional settings from US date format to a region that uses dd/mm/yyyy date format, not US date format mm/dd/yyyy, you will no longer have that problem.

Currently, your computer date format does not match the csv date format.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
3
May 19, 2021 - 8:07 pm
sp_Permalink sp_Print

Just for information (since Power Query is a better option if you have it), the problem is that you specified the date format for the wrong columns - you did it for column 6, but you actually need it for 7, 8 and 9:

 

Range("A:A").TextToColumns , DataType:=xlDelimited, Semicolon:=True, TextQualifier:=xlDoubleQuote, _
FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, xlDMYFormat), Array(8, xlDMYFormat), Array(9, xlDMYFormat), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _
Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array( _
33, 1), Array(34, 1), Array(35, 1)), TrailingMinusNumbers:=True

sp_AnswersTopicAnswer
Answers Post
Avatar
Sebastian Fuentes

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
April 8, 2021
sp_UserOfflineSmall Offline
4
May 20, 2021 - 5:08 am
sp_Permalink sp_Print

Dear Velouria and Catalin,

Thanks for the reply, was really helpful. I have switched to Power Query.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Riny van Eekelen, Albert Hislop, Kumud Patel, Bright Asamoah
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Fred Smith
Charles DeGraffenreaid
Cathi Giard
Sarah Young
Henry Delgado
Alita Nieuwoudt
KL KOH
Forum Stats:
Groups: 3
Forums: 24
Topics: 6360
Posts: 27812

 

Member Stats:
Guest Posters: 49
Members: 32340
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.