Hi Guys
I have a csv file which when i convert to a text file, displays commas for every empty cell in the work book. I do require this to happen however at the end of each row, there appears to be several commmas.
Is there any way in which i can remove them.
i have seen some code online which kills the comma at the end But this requires two files to stay in one location, ideally i would like to put some vba code into the file im working on.
Does anyone have a solution?
Many Thanks
Shil
Sub CommaKiller()
Dim TextLine As String, comma As String
comma = ","
Close #1
Close #2
Open "c:\alpha.csv" For Input As #1
Open "c:\omega.csv" For Output As #2
Do While Not EOF(1)
Line Input #1, TextLine
l = Len(TextLine)
For i = 1 To l
If Right(TextLine, 1) = comma Then
TextLine = Left(TextLine, Len(TextLine) - 1)
End If
Next
Print #2, TextLine
Loop
Close #1
Close #2
End Sub
Bookmarks