I have a csv file that I need to manipulate so that I can imported into another application. I need to add a comma & a space to the end of each cell with data in it (minus the header row) & then export the entire range into a single line in a text file. For example, the contents of column A in the attached file should be exported into a txt file looking like below. The amount & data in column A will always change and I am having issues even saving the file as a text file. When I use the code below it will create a text file but with no data in it, any help would be greatly appreciated!
105J1V3, 10RHPV2, , 10T0C53, 10WXMM3, 115J1V3, 11WXMM3, 123B043, 135J1V3, 13GXMN3, 1485Z43, 14C9LN3, 15605K3
105J1V3, 10RHPV2, , 10T0C53, 10WXMM3, 115J1V3, 11WXMM3, 123B043, 135J1V3, 13GXMN3, 1485Z43, 14C9LN3, 15605K3
VBA Code:
Private Sub Workbook_Open()
Dim rng As Range
Set rng = ActiveSheet.UsedRange
Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)
rng.Select
Dim c As Range
For Each c In Selection
If c.Value <> "" Then c.Value = c.Value & ", "
Next
'object to use as folder
Dim fld As Object
Set fld = CreateObject("Scripting.FileSystemObject")
'using create text file method
Dim myFile As Object
Set myFile = fld.CreateTextFile("C:\temp\MKrautler\Tags.txt", True)
End Sub