Const ForReading = 1
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
strSource = "C:\Users\Desktop\test.csv"
Set File = fso.OpenTextFile(strSource, ForReading)
strText = File.ReadAll
File.Close
strNewText = Replace(strText,",","|")
Set File = fso.OpenTextFile(strSource, ForWriting, True)
File.WriteLine strNewText
File.Close
This is the code Im using and the result I get is: xxxx|yyyy|zzzzz||||||||||||||||||||| The pipe character '|' must be replaced with 'null' or '' if its repeated more than five times and I have tried using trim, replace and mid functions but couldn't get the solution. Thanks