Ladies and Gentlemen, I'm stumped and would appreciate your expertise. I have researched this here and elsewhere, but the answer eludes me.
Summary: I just want to export each row of an Excel file to a new file, but I must have the same header row for each file. Also, some cells are blank, but they still must be included.
Details:
Excel Worksheet with 13 Columns (A-M) and 11 Rows (1-11)
Row 1 is the header row which must be included in each file
Contents of each row must be exported to a new file
Column A for each row is used for the name of the new file
If any Cells are blank, EXCEPT Column 1, they still must be included in the new file.
Script should continue until a blank value in Column A
I need to be able to code the directory for the output.
I will attach what I have so far - not elegant, it works, but does not give me what I need.
It only takes the individual row with no header and exports to the directory where the workbook is open.
Sub ExportRows()
Dim r As Range, r2 As Range
Dim ff As Integer
Dim s As String
For Each r In Range("a1", Range("a" & Rows.Count).End(xlUp))
s = ""
For Each r2 In Range(r, Cells(r.Row, Columns.Count).End(xlToLeft))
If VarType(r2) = vbString Then
s = s & "," & """" & r2.Value & """"
Else
s = s & "," & r2.Value
End If
Next r2
s = Right(s, Len(s) - 1)
ff = FreeFile
Open ThisWorkbook.Path & "\" & Format(r.Row, "000000") & ".au" For Output As #ff
Print #ff, s
Close #ff
Next r
End Sub
Worksheet.jpg
Bookmarks