I have the next macro to convert txt with tab delimited columns to xlsx. For columns with short data in cells nor problem it does very good the macro. However with cells that has very long texts or maybe some special characters the macro trunks the data and is wrongly placed some information to column A or other places where it doesn’t correspond. Check photo check the text with red circles that text is from previous row and it was truncated and passed there in column A next row. If I drag and drop manually (not using the macro) that txt with tab delimited columns in excel is processed very good no matter the length of the cells or special characters. If I convert with the macro as you see in red circles is truncated text to other columns/rows it doesn’t correspond. What would be required to fix the script and avoid it truncates or destroy the text as seen in red circles.
Public Sub Read_TXT()
Dim Dir_p As String, File_to_Open As String
Dir_p = ActiveWorkbook.Path
File_to_Open = Dir(Dir_p & "\")
While File_to_Open <> ""
If InStr(1, Right(File_to_Open, 3), "txt", vbTextCompare) <> 0 Then
Workbooks.OpenText fileName:=Dir_p & "\" & File_to_Open, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, _
TrailingMinusNumbers:=True
ActiveWorkbook.SaveAs fileName:=Dir_p & "\" & Left(File_to_Open, Len(File_to_Open) - 3) & "xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
End If
File_to_Open = Dir
Wend
End Sub
Thank you