VBA Updating worksheets before PDF printed based on dropdown in other worksheet

Gem1979

New Member
Joined
Aug 28, 2014
Messages
19
Hi, hoping someone can help. Think it's quite simple but I'm stuck! I have the following code which loops through a dropdown on Sheet1 and subsequently prints two other worksheets to PDF. Both worksheets have a cell linked to G5 on Sheet 1 and values in those worksheets should update based on each selection before the PDFs are printed but they're not updating. I therefore get 30 PDFs with the same values on. How do I get the two other worksheets to update as each dropdown value is looped through? Many thanks in advance.

Code:
Sub Create_pdf_pack()
Dim dvCell As Range
Dim inputRange As Range
Dim c As Range
Set dvCell = Sheets(1).Range("G5")
Set inputRange = Evaluate(dvCell.Validation.Formula1)
For Each c In inputRange
[G5] = c.Value
'you might need to refresh the sheet here
ThisWorkbook.Sheets(Array("Targets - Retailer PDF", "Model Sheet - Retailer PDF")).Select
ActiveSheet.Calculate
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="G:\MBC National Sales\Forecast\2020\Targets\Targets & model Retailer\2020 Target & Model " & c.Value, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next c

MsgBox "All PDF's have been successfully exported."
End Sub
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,943
Messages
6,122,370
Members
449,080
Latest member
Armadillos

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