Need VBA Code to print pdf and save excel at same time with cell as file location and file name

oconee1985

New Member
Joined
Apr 19, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi, I am new to using VBA and bumbling my way thru. Im using excel professional plus 2016

I have a workbook with multiple worksheets. To give you some background I one worksheet that I enter an account number and I pull data from the other sheets. Additionally, I have set the print area on this worksheet for just the area that I need printed. Once I have pulled the data I need I then have to print the page to a pdf and then save the excel file with a new name and then start all over on the next account. What I would like to be able to do is to have three cells that have data I need the command to use

A1 Account Number (which will be the pdf and excel file name)
A2 folder location / file path to save pdf to (note this path will change every day)
A3 folder location / file path to save excel to (note this path will change every day)

So to summarize when I press the command button it will automatically print to a pdf using the data in A1 as the file name and A2 as the file path AND at the same time save the entire current workbook to file path listed in A3 using the account number as the file name which is located in A1.

Hopefully this gives all the data that is needed. I appreciate any help or feedback.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,376
Messages
6,119,178
Members
448,871
Latest member
hengshankouniuniu

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