Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
txt tab delimited with columns to xls convert macro problem

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

enter image description here

Thank you

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!