title: EXCEL VBA : Creating a simple loop to repeat a process for each row
body: <p>I know it might seem to be a very simple question but I tried different methods to create a loop that would do what I'm looking for:
  Basically I have an excel sheet with 4 columns (unknown number of rows) in which I want to enter data. This data is then mirrored to a second sheet that contains the "printing design" that I use to create multiple PDF files.
  Problem is: I tried for 4 days now to create a loop and have not achieved anything!</p>
  
  <p>If you could help me, this is the data entry:
  <a href="https://gaussschule-bs.de/idesk/file/pass.php/Files/Homepage/example.JPG" rel="nofollow">SCREENSHOT</a></p>
  
  <pre><code>Public Sub InputData()
  
  Dim strCap As String
  strCap = Sheets("INPUT").Cells(4, 3).Value
  Label1.Caption = strCap
  
  Dim strCap2 As String
  strCap2 = Sheets("INPUT").Cells(4, 5).Value
  Label2.Caption = strCap2
  
  If Sheets("INPUT").Cells(4, 4) = "OE" Then
      Image1.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\OE_Logo.jpg")
  Else
      Image1.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\SF_Logo.jpg")
  End If
  
  If Sheets("INPUT").Cells(4, 6) = "OE" Then
      Image2.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\OE_Logo.jpg")
  Else
      Image2.Picture = LoadPicture(ActiveWorkbook.Path &amp; "\SF_Logo.jpg")
  End If
  
  Application.Calculate
  
  Call PrintPDF
  
  End Sub
  
  
  Sub PrintPDF()
  Dim pdfjob As Object
  Dim sPDFName As String
  Dim sPDFPath As String
   '/// Change the output file name here! ///
  sPDFName = "Affidavit" &amp; " " &amp; Sheets("INPUT").Cells(4, 3) &amp; "_" &amp; Sheets    ("INPUT").Cells(4, 5) &amp; ".pdf"
  sPDFPath = ActiveWorkbook.Path &amp; Application.PathSeparator
   'Check if worksheet is empty and exit if so
  If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
  Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
  With pdfjob
      If .cStart("/NoProcessingAtStartup") = False Then
          MsgBox "Can't initialize PDFCreator.", vbCritical + _
          vbOKOnly, "PrtPDFCreator"
          Exit Sub
      End If
      .cOption("UseAutosave") = 1
      .cOption("UseAutosaveDirectory") = 1
      .cOption("AutosaveDirectory") = sPDFPath
      .cOption("AutosaveFilename") = sPDFName
      .cOption("AutosaveFormat") = 0 ' 0 = PDF
      .cClearCache
  End With
   'Print the document to PDF
  
  Sheets("AFFIDAVIT CREATOR").PrintOut Copies:=1, From:=1, To:=1, ActivePrinter:="PDFCreator"
   'Wait until the print job has entered the print queue
  Do Until pdfjob.cCountOfPrintjobs = 1
      DoEvents
  Loop
  pdfjob.cPrinterStop = False
   'Wait until PDF creator is finished then release the objects
  Do Until pdfjob.cCountOfPrintjobs = 0
      DoEvents
  Loop
  pdfjob.cClose
  Set pdfjob = Nothing
  End Sub
  </code></pre>
  
  <p>I actually want to create One SINGLE PDF file for each row, so do this for row 4, 5, 6 etc. till VBA finds an empty row.</p>
  
  <p>Any help would be highly appreciated, thanks in advance for all the help I was able to find on Stackoverflow and hopefully help to come!</p>
  
  <p>Thanks,</p>
  
  <p>Yannick</p>