Good day all,
I have an Excel workbook with various sheets inside, each of these sheets must be converted to a PDF in sequential order. i.e. Lab 1, Lab 2, Lab 3, Lab 4, etc.
The issue I run into sees my macro run, however it only creates one PDF file and it doesn't number the report (Lab 1, Lab 2, etc.) as I had hoped. I'm hoping someone here can show me the error I'm missing. The code is below, however I've changed some of the file destination information to make it generic looking. Please forgive my ignorance, I'm still relatively new to this whole VBA thing. 
(Also, please forgive me for not uploading the workbook, it's on a government server and they're not too happy to see proprietary information uploaded to the web.) Thank you in advance!
Sub Printpdf()
'
' Printpdf Macro
'
' Keyboard Shortcut: Ctrl+p
'
Dim num As Integer
Dim x As Integer
For num = 1 To 4
' Here I actually have 130 (not 4) laboratories which need to have their individual results saved and converted to PDF
Sheets("Indv Rep").Select
Range("A2:k63").Select
x = num
Selection.Replace what:="$" & num, Replacement:="$" & num + 1, LookAt:=xlPart, _
Searchorder:=xlByRows, MatchCase:=False
If Range("B7").Value <> 0 Or Range("B22").Value <> 0 Or Range("B39").Value <> 0 Then
Sheets(Array("indv rep", "chart1", "chart2")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\Folder 1\Folder 2\Folder 3\Folder 4\Folder 5\Lab " & Worksheets("Indv Rep").Range("A2").Value & ".pdf", OpenAfterPublish:=False
' Again, I would like to name each PDF sequentially. Like "Lab 1", "Lab 2" etc. through "Lab 130"
End If
Next num
Selection.Replace what:="$" & x + 1, Replacement:="$2", LookAt:=xlPart, _
Searchorder:=xlByRows, MatchCase:=False
End Sub
Bookmarks