Hi,
I am stuck. I want to combine a txt file with the content of a cell and another txt file to form a new txt file. (SourceFile1.txt + cell content + SourceFile2.txt = OutputFile.txt).
I have a table with column with several values. I would like to have one File for each Cell in that collumn.
yvbjOrU.jpg
For example:
Outputfile 1:
Sourcefile 1
A1
Sourcefile 2
Outputfile 2:
Sourcefile 1
A2
Sourcefile 2
Outputfile 3:
Sourcefile 1
A3
Sourcefile 2
My sourcecode so far (doesn't work):
Sub SaveFile()
Source1 = FreeFile()
Open "D:\Source1.txt" For Input As Source1
Source2 = FreeFile()
Open "D:\Source2.txt" For Input As Source2
Do While Not IsEmpty(ActiveCell.Offset(0, 1))
MyFile = ActiveCell.Value & ".txt"
output = FreeFile()
Open MyFile For Output As output
Do While Not EOF(Source1)
Line Input #Source1, Temp
Print #output, Temp
Loop
Print #output, ActiveCell.Offset(0, 1) & " " & ActiveCell.Offset(0, 2)
Do While Not EOF(Source2)
Line Input #Source2, Temp
Print #output, Temp
Loop
Close #output
ActiveCell.Offset(1, 0).Select
Loop
Close #Source1
Close #Source2
End Sub
I hope someone can point me in the right direction or give a working source code!
Thank you :-)
[Edit]
Image for clarification:
gfx.jpg
Bookmarks