Reputation: 13
i want to insert multiple values in a single cell and export every single entry as a separate pdf. The only thing i did till know is to manually reference the cells and export them as pdfs. This is my macro:
Sub SavePDF()
Range("A8").Value = Range("A8").Value + 1
Sheet3.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\Report_" & _
ActiveSheet.Range("A8").Value & ".pdf", _
OpenAfterPublish:=False
End Sub
Lets say that i have a range: M6:M14
and i want to input the results in the cell "M1". After i start the macro i want ot create for every single value (the value should be inside the pdf) a new pdf. Example: for the value of M6 a pdf, for M7 another and so on till i reach M14.
Upvotes: 0
Views: 119
Reputation: 14383
Please try this code.
Sub SavePDF()
Dim NameRange As Range
Dim i As Integer
Dim PdfName As String
Set NameRange = Range("M6:M14")
For i = 1 To NameRange.Cells.Count
PdfName = Trim(Range("A8").Value) & i
With Sheet3
.Range("M1").Value = NameRange.Cells(i).Value
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="C:\Users\Report_" & PdfName & ".pdf", _
OpenAfterPublish:=False
End With
Next i
End Sub
Upvotes: 2