I think I am close on this, but it is not quite working as intended. The first version of this VBA was originally created to loop through a list on the "CertData" sheet and print the output as a defined range on sheet "Certificate". This worked perfectly, but I would rather have it loop through the list and save each range as a PDF file. The code below kind of works, I can see it on the screen as it loops through all the rows from the "CertData" sheet, but it only saves a single PDF file and that is the data from the last row, but names the file from data in the first row. I am really scratching my head on this one as it seems the line rng.export... should fire off with each step of the loop just like it did when the output was set to PrintOut.
VBA Code:
Sub PrintCerts()
Dim i As Long, LastRow As Long
Dim SaveLocation As String
Dim rng As Range
SaveLocation = "C:\Users\dkone\Desktop\PDF_Print_Output\": NewName = SaveLocation & Range("P8").Text & "_" & Range("P10").Text & ".PDF"
Set rng = Worksheets("Certificate").Range("A1:M39")
LastRow = Worksheets("CertData").Range("A65536").End(xlUp).Row
For i = 1 To LastRow
If Not Worksheets("CertData").Range("A" & i).Value = 0 Then
Worksheets("Certificate").Range("P5").Value = Worksheets("CertData").Range("A" & i).Value
rng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=NewName
' Worksheets("Certificate").Range("A1:M39").PrintOut - this line worked fine with the loop and I would get 1 printout for each step of the loop, when this line was used, I wasn't using the Dim rng
End If
Next i
End Sub