Sub Macro1()
Set temp = Sheets("Template")
Set d = Sheets("Data")
OutputDir = temp.Range("c1")
Filename = temp.Range("c2")
Nbtemplatelines = temp.Range("c3")
Nbdatalines = temp.Range("c4")
Nbdatacolumns = temp.Range("c5")
Open OutputDir & "\" & Filename & "_" & d.Cells(2, 1) & ".xml" For Append As #1
For t = 1 To Nbdatalines
For i = 1 To Nbtemplatelines
LineToPrint = temp.Cells(i, 1)
For j = 1 To Nbdatacolumns
LineToPrint = Replace(LineToPrint, "%" & d.Cells(2, j) & "%", d.Cells(t + 3, j))
Next j
Print #1, LineToPrint
Next i
Next t
Close #1
End Sub