Loop Macro


I am using the below macro for generating individual XML files I would like to generate them in a batch.

Please let me know how do I modify/alter the code to do the same:-

Private Sub CommandButton1_Click()

Dim iCntr

Dim strFile_Path As String

 Dim Filename As String

‘Change cell reference accordingly

 Filename = Sheets(“Sheet2”).Range(“C10”)


 ‘Filename = InputBox(“Enter File Name”, “File Name”, 8)


strFile_Path = “C:\Users\temp\” & Filename & Format(Now(), “dd-MMM-yyyy h-m-s”) & “.xml”

 Open strFile_Path For Output As #1

 For iCntr = 2 To 2329

Print #1, Sheets(“Sheet1”).Range(“D” & iCntr)

Next iCntr

 Close #1

End Sub



Top Contributor Asked on November 26, 2017 in VBA: Macros.
Add Comment
0 Answer(s)
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.