Hi all, i need help writing a macro that copies specific data from each row of a workbook and puts it into a separate dat file for each row. So far i was able to write something up that only works for the first row(seconf beneath header). How can i modify this to export each row on a separate file - again, having some custom ordering applied same as i do below
Sample data:
<tbody>
</tbody>
Sample data:
Project name | Client | First name | Last name | userid |
JHGH | Nike | John | Doe | johnd |
VBNM | Coca Cola | Jane | Doe | janed2 |
<tbody>
</tbody>
Code:
Option Explicit
Sub TEST()
Dim fso As Object, opStr As String
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Fileout As Object, fPath As String
fPath = ThisWorkbook.Path & "\" & Data.Range("A2") & "-" & Format(Now, "MM.DD.YYYY") & ".dat"
Set Fileout = fso.CreateTextFile(fPath, True, True)
opStr = "SOME HARDCODED TEXT &" _
& Data.Range("A2") & "|" & Data.Range("B2") & "|" & Data.Range("C2") & "|" & Data.Range("D2")
Fileout.Write opStr
Fileout.Close
MsgBox "Done. File: " & fPath
End Sub