Every month I have a dashboard that needs to have a pdf created for each person provided on a drop down list. I created a code that loops through that drop down list and creates a pdf for each person. One of my bosses asked me to add pages to that pdf based on if they meet a certain condition. I created a version of that page on a different worksheet and I want the loop to go through each person on the dropdown list but also attach the other worksheets to the end of that same pdf if they meet the conditions to have that worksheet be attached.
Here is a simplistic version of that excel sheet
So the VBA should loop through the drop down list, check to see if conditions on bottom are met and should print the original sheet and the sheets that meet the conditions.
I have a print area set in all the sheets through page layout, as long as it prints the sheet it should just catch that print area, at least that is what it has been doing so far.
That's the tab that where it loops through the names to reload the original sheet each time it loops through to export, also column two is used in the naming convention
So I need to add to that loop for it to check that range in the original sheet each time and if the condition says yes then attach the corresponding worksheet to the exported pdf.
Thank you in advance.
Here is a simplistic version of that excel sheet
So the VBA should loop through the drop down list, check to see if conditions on bottom are met and should print the original sheet and the sheets that meet the conditions.
I have a print area set in all the sheets through page layout, as long as it prints the sheet it should just catch that print area, at least that is what it has been doing so far.
That's the tab that where it loops through the names to reload the original sheet each time it loops through to export, also column two is used in the naming convention
VBA Code:
Sub VenA()
c00 = "File Path" 'Just change the path
ar = Sheets("People").ListObjects(1).DataBodyRange
lm = Format(DateAdd("m", -1, Date), "yyyymm")
With Sheets("Original")
For j = 1 To UBound(ar)
.Range("E3") = ar(j, 1)
.ExportAsFixedFormat 0, c00 & "Report_" & lm & "_" & ar(j, 2) & ".pdf"
Next j
End With
End Sub
So I need to add to that loop for it to check that range in the original sheet each time and if the condition says yes then attach the corresponding worksheet to the exported pdf.
Thank you in advance.