Forum Discussion
redblooda
Nov 13, 2020Copper Contributor
Saving as PDF depending on Cell Value
Hi, I'm pretty new to the macros. So any help would be great. What I want to do is; 1- I need Cell "A2" in sheet "B3" to change to the values between "B7:B169" in sheet "VerTab" 2- Then save she...
HansVogelaar
Nov 13, 2020MVP
Like this:
Sub SaveAsPDF()
Dim i As Long
Dim VList As Variant
Dim fName As String
VList = Worksheets("VerTab").Range("B7:B169").Value
For i = LBound(VList) To UBound(VList)
With Worksheets("B3")
.Range("A2") = VList(i, 1)
fName = "C:\Users\Redblood\Documents\datasheet\" & VList(i, 1)
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Next i
End Sub