loop through drop down list creating pdf files

IIJJII

New Member
Joined
Feb 4, 2016
Messages
8
I have a drop down list in cell AD5 of Sheet1. When I select each item in the list, Sheet1 updates with the appropriate values. I am trying to loop through each item in the drop down list and then export Sheet1 as a pdf. The code I have so far just exports the same item in the list and doesn't actually loop through, how can I change this? Here is my code so far:

Code:
Sub Create_pdf_pack()


     Dim inputRange As Range
     Dim c 'As Range
     
     Set inputRange = Evaluate(Range("AD5").Validation.Formula1)
               
        For Each c In inputRange
       
            ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            fileName:="C:\test\" & c.Value, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
               
        Next c


End Sub
 
Try...

Code:
Sub Create_pdf_pack()


     Dim inputRange As Range
     Dim c As Range
     
     Set inputRange = Evaluate(Range("AD5").Validation.Formula1)
               
        For Each c In inputRange
        
            [COLOR=#ff0000]Range("AD5").Value = c.Value[/COLOR]
       
            ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:="C:\test\" & c.Value, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
               
        Next c


End Sub
 
Upvote 0
Try...

Code:
Sub Create_pdf_pack()


     Dim inputRange As Range
     Dim c As Range
     
     Set inputRange = Evaluate(Range("AD5").Validation.Formula1)
               
        For Each c In inputRange
        
            [COLOR=#ff0000]Range("AD5").Value = c.Value[/COLOR]
       
            ActiveSheet.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:="C:\test\" & c.Value, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
               
        Next c


End Sub


Hi Domenic,
Thanks for the code provided. It's almost working for me.
Could you take a look at my thread and let me know if you can help? Much appreciated
http://www.mrexcel.com/forum/excel-...ations-close-but-not-working.html#post4485699
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top