# VBA to cycle through drop down list and save as pdf with file name



## Carla carla (Oct 29, 2022)

Hello, I need help on saving my drop down list to individual pdf file with file name.


----------



## John_w (Oct 29, 2022)

More details are required to help you.  What type of the drop down is it?  Where should the PDF files be saved (folder)?

See if you can adapt this code, which is for a data validation drop down.









						cycle through data validation list to print to pdf and save as cell text
					

Hi, I have: - worksheet name("test1") - data validation list in "A" - print range is first page of worksheet or A1: I45  looking if there's a way to have macro that cycles through the data validation list and prints a PDF with the name of the text in that cell and loop through so every item of...




					www.mrexcel.com


----------



## Carla carla (Oct 29, 2022)

The drop down list- is a data validation list
Yes, the pdf must be saved in a folder


----------



## Carla carla (Oct 29, 2022)

John_w said:


> More details are required to help you.  What type of the drop down is it?  Where should the PDF files be saved (folder)?
> 
> See if you can adapt this code, which is for a data validation drop down.
> 
> ...


Hello, it worked for me! Thank you but one more thing how to they set the name of the file?


----------



## John_w (Oct 29, 2022)

Carla carla said:


> how to they set the name of the file?


The file name is the current Data Validation cell value, as it loops through each Data Validation value, set by this part of the code:


```
Filename:=destinationFolder & dvValueCell.Value & ".pdf"
```


----------



## Carla carla (Dec 31, 2022)

John_w said:


> The file name is the current Data Validation cell value, as it loops through each Data Validation value, set by this part of the code:
> 
> 
> ```
> ...



Is there anyway for me to change the filename, ID number too dificult


----------



## John_w (Dec 31, 2022)

If each ID number is related to a value in a table, maybe you could have a LOOKUP/VLOOKUP formula whose result the code reads to use as the file name.  But we need more information about your exact sheet layout and details to do that - posting your sheet(s) with the XL2BB add-in would help.


----------

