Loop Macro


I am using the following macro for generating XML file, however I want to run this in loop and generate multiple files, each file should have an assignee id(see client id) picked from a sheet and populate the appropriate numbers in the Input Sheet (see import)

Loop MacroClient ID

Loop MacroAmount

Loop MacroImport

Private Sub CommandButton1_Click()
Dim iCntr
Dim strFile_Path As String
Dim Filename As String
'Change cell reference accordingly
Filename = Sheets("Input").Range("C6") & "" & Sheets("Input").Range("C7") & "" & Sheets("Input").Range("C9") & ""
strFile_Path = "C:\Temp\CCH\" & Filename & "" & Format(Now(), "dd-MMM-yyyy h-m-s") & ".xml"
Open strFile_Path For Output As #1
For iCntr = 1 To 1110
Print #1, Sheets("Import").Range("D" & iCntr)
Next iCntr
Close #1
End Sub
Top Contributor Asked 3 hours ago 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.