Hello Excelforum community,
This is the first time posting on this forum but I've been a long time "leecher". I am in need of a complex macro that will parse through contents of a worksheet and make mutiple .txt documents. I've tried searching online and through these forums but without any luck. I currently have this...
Example Data:
A1
0/Cat
1/Young
1/Old
1/Mid Age
0/Dog
1/Old
1/Mid Age
0/Gerbil
1/Young
1/Old
1/Mid Age
I want the outcome to be three txt documents:
0/Cat
1/Young
1/Old
1/Mid Age
0/Dog
1/Old
1/Mid Age
0/Gerbil
1/Young
1/Old
1/Mid Age
I think what I am looking for is a loop that will parse the sheet and look for the next "0" value. Then something to transform it into mulitple text documents.
I am currently this code to save the entire worksheet but I need the loop:
Sub Save()
Dim FilePath As String
Dim FileName As String
FileName = "Animal_" & Worksheets("Animals").Range("A2").Value & "_" & _
Format(Now, "yyyy-mm-dd") & "_" & Format(Now, "hhmmss") & ".txt"
FilePath = "C:\"
Dim FileNo As Integer
Dim x As Long
FileNo = FreeFile
Open FilePath & FileName For Output As #FileNo
With Sheets(9)
For x = 1 To .Range("A1:A" & .Range("A15536").End(xlUp).row).Count
Print #FileNo, .Cells(x, 1).Value
Next x
End With
Close #FileNo
End Sub
I am also wondering if it is even possible to do this? If not, should I stop trying? Are there any other methods?
Any help would be greatly appreciated.
Bookmarks