I am trying to open all csv files (semicolon delimited) in a directory, and this is the code that I think should work:
Sub test() Dim MyFile As String Dim MyDir As String MyDir = Application.ActiveWorkbook.Path MyFile = Dir(MyDir & "\" & "*.csv") 'set current directoy ChDir MyDir Application.ScreenUpdating = 0 Application.DisplayAlerts = 0 Do While MyFile <> "" Workbooks.Open (MyFile) 'Parse it using semicolon as delimiters Range(Range("A1"), Range("A1").End(xlDown)).TextToColumns _ DataType:=xlDelimited, _ ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=True, Comma:=False, Space:=False, Other:=False ' 'next file in directory MyFile = Dir() Loop End Sub
But, strangely enough, it also uses a comma as a separator. I see that if I debug a TextToColumns string.
So for a csv file for example
test;test,test
I would expect a way out
test test,test
But I really get
test test
Why? Is there something wrong with my settings in Excel?
Thanks!
source share