Creative carla
New Member
Hello,
I am using the macro below to generate pdf files from data validation list. As of now the file name is the from the data validation on B2. how can I set it as so that the filename source becomes A2??
>>> use code - tags <<<
I am using the macro below to generate pdf files from data validation list. As of now the file name is the from the data validation on B2. how can I set it as so that the filename source becomes A2??
>>> use code - tags <<<
Code:
Public Sub Create_PDFs()
Dim destinationFolder As String
Dim dataValidationCell As Range, dataValidationListSource As Range, dvValueCell As Range
destinationFolder = ThisWorkbook.Path 'Same folder as workbook containing this macro
'destinationFolder = "C:\path\to\folder\" 'Or specific folder
If Right(destinationFolder, 1) <> "\" Then destinationFolder = destinationFolder & "\"
'Cell containing data validation in-cell dropdown
Set dataValidationCell = Worksheets("test1").Range("B2")
'Source of data validation list
Set dataValidationListSource = Evaluate(dataValidationCell.Validation.Formula1)
'Create PDF for each data validation value
For Each dvValueCell In dataValidationListSource
dataValidationCell.Value = dvValueCell.Value
With dataValidationCell.Worksheet.Range("A1:I45")
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=destinationFolder & dvValueCell.Value & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Next
End Sub
Last edited by a moderator: