I found a great macro when searching that exports each row to a seperate file perfectly (sorry, didn't get the author to give credit), but I need the column header to be the first line in the text file, then the row of data. Can someone help me with the edit to include that info?
Sub WriteText()
Dim firstrow As Integer, rownum As Integer, colnum As Integer
Dim filename As String
Dim Filelocation As String
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Filelocation = "C:\users\hansenbrad\My Documents\QuestFiles\"
With ws
rownum = 2
While .Cells(rownum, 1) <> ""
filename = .Cells(rownum, 1).Value
Open (Filelocation & filename & ".txt") For Output As #1
colnum = 1
While .Cells(rownum, colnum) <> 0
Print #1, ws.Cells(rownum, colnum) & " ";
colnum = colnum + 1
Wend
Close #1
rownum = rownum + 1
Wend
End With
End Sub
Bookmarks