The solution on Rowan really works. The key replaces the file name "Test.csv" in its solution "Test.txt" in your "\ CSV_Files \" location. "Test.txt" should not be a separate type of comma value. It must be a true TXT file type.
Check the file type in Windows Explorer. Make sure it is not a CSV. If you use the CSV type, you will actually tell Excel, the data is parsed with a comma, not a delimiter.
If your book is located in the root: c: \ Create a directory: C: \ CSV_Files Place the text file: Test.txt in the \ CSV_Files directory
In your book, open VBA and copy the full VBA code below.
The full VBA code should look like this:
Sub OpenCSV() Dim wkbTemp As Workbook Dim sPath As String, sName As String sPath = ThisWorkbook.Path & "\CSV_Files\" sName = "Test.txt" Workbooks.OpenText Filename:=sPath & sName, _ Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _ , Comma:=False, Space:=False, Other:=True, OtherChar:="|" Set wkbTemp = ActiveWorkbook end sub
Close VBA and run the macro.
source share