Try something like this.
Change the red items to suit; - invoice start and end ID numbers
- the "corresponding cell" sheet name and cell address
- Sheet Name to save as PDF
- File path for the PDF file
Sub Save_Invoice_PDFs()
Dim IDStart As Long, IDEnd As Long, ID As Long, strID As String
IDStart = 1 'Invoice start number
IDEnd = 10 'Invoice end number
For ID = IDStart To IDEnd
'Format ID number
strID = "InvoiceID_" & Format(ID, "000")
'Write ID number to 'corresponding cell'.
Sheets("Sheet1").Range("A1").Value = strID
'Save sheet as PDF
Sheets("Sheet1").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\MyFolder\" & strID & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next ID
MsgBox "Invoices saved as PDF.", , "Invoice Save Complete"
End Sub
Bookmarks