VBA code to save as a PDF but let user choose location and file name?

Hayley Howells

New Member
Joined
May 20, 2014
Messages
6
Hi there, have had some fab help from this forum before so hoping someone can help me this time.

I'm looking for some VBA code to be linked to a button that selects all unhidden worksheets, then saves the selected sheets as a PDF, whilst allowing the user to select the save location on our network, and also letting the user choose the file name.

The background to this is that our team looks after 100 contractors, and I have 5 tabs in the workbook that use a drop down list to show data relevant to each contractor, but our admin team is going to generate the PDFs in advance of a programme of visits, so I need a user friendly button.

Ideally, within the VBA, there would also be a facility for the contractor name to be updated based on the admin staff selecting it once, on the front page (ie updating the selection on the summary page also cascades an update onto other pages.

Code wise, as far as I have got is to select all the sheets:

Sheets(Array("1.Practice Summary", "2.Generic Savings", "3.Not Recommended", "4.Items Less Suitable", "5.Specials")).Select

Not very far... I know!!!

In a perfect world, before selecting sheets, the cascade would occur with the contractor name (as selected on "Practice summary"), then after selecting all sheets, it would be saved as PDF within the users chosen location/file name. If it makes a difference, the contractor name is in the same cell on each sheet (B1).

Hope that makes sense! Any help appreciated!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,112
Messages
5,857,450
Members
431,880
Latest member
kar2rost

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
Top