title: Convert Excel rows to PDF pages using VBA
body: <p>I have data in Excel with student names and their marks.
  I want to export the data to PDF using VBA macro where each student details appear on a different PDF page. So if there are 20 students then there will be 20 pages in single PDF. Each student name will form heading of the PDF page and their marks will appear in a table below the heading.</p>
  
  <p>I have a table like this in Excel</p>
  
  <pre><code>student name  -  erp  -    science marks        -geography marks
                             test1  test2          test1  test2  test3
  peter         -  12        15      9.5           15      7      11
  jack          -  13        16      11            10      9      13
  </code></pre>
  
  <p>How can I export this data in a PDF like <code>student.pdf</code>, where page1 will have peter name as heading and the sum of his science marks and geography marks. Similarly, page2 will have jack's name and sum of his marks. How can I do that?</p>
  
  <p>Also, the number of students is dynamic. So I have to count the number of students and that will be the count of my PDF. How do I do that?</p>
  
  <p>code so far</p>
  
  <pre><code>Sub convertTopdf()
  Dim ws As Worksheet
  Dim lastRow As Long
  
  ChDir "C:\Users\Dell\Desktop"
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
      "C:\Users\Dell\Desktop\task_excel\POD.pdf", OpenAfterPublish:=True
  
  Set ws = ActiveWorkbook.ActiveSheet
  With ws
      lastRow = .Range("A" &amp; .Rows.Count).End(xlUp).Row
  End With
  
  MsgBox "The last row which has data in Col A of Sheet1 is " &amp; lastRow
  
  End Sub
  </code></pre>