Sub Data2Text()
Dim fs, obj As Object
Dim Folder, FileName, Text As String
Dim lR, i, c As Long
Folder = ThisWorkbook.Path & "\"
FileName = " Report_Sample.txt"
lR = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lR
For c = 1 To 6
Text = Text & Sheets(1).Cells(i, c).Value
If c < 6 Then
Text = Text & "; ;"
Else
Text = Text & vbNewLine
End If
Next
Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set obj = fs.CreateTextFile(Folder & FileName, True)
obj.WriteLine (Text)
obj.Close
Set fs = Nothing
End Sub
Bookmarks