I am converting a excel output into .txt and .dat file format, but whenever I convert it to .txt file the remaining spaces or empty columns gives a lot of comma on converted text file.
=IF(A13="","", IF(LEFT(A13,1)="T","", IF('JPMorgan Template New'!A14<>"",'JPMorgan Template New'!A14&'JPMorgan Template New'!B14&'JPMorgan Template New'!C14&'JPMorgan Template New'!D14&'JPMorgan Template New'!E14&'JPMorgan Template New'!F14&'JPMorgan Template New'!G14&" "&'JPMorgan Template New'!H14&" "&'JPMorgan Template New'!I14&'JPMorgan Template New'!J14&" "&'JPMorgan Template New'!K14&" "&'JPMorgan Template New'!L14&'JPMorgan Template New'!M14&" "&'JPMorgan Template New'!N14&'JPMorgan Template New'!O14&'JPMorgan Template New'!P14&" "&'JPMorgan Template New'!Q14&'JPMorgan Template New'!R14&'JPMorgan Template New'!S14,"T"&MIN(ROW(A14:A15))+ROWS(A14)-3&" " & SUM('JPMorgan Template New'!H:H))))
Sub SaveAsTXT()
Dim parts As Variant
parts = Split(ActiveWorkbook.Name, ".")
parts(UBound(parts)) = ".txt"
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & _
Join(parts, "."), FileFormat:=xlCSV, CreateBackup:=False
End Sub