VBA save to PDF

buffalobill

New Member
Joined
Mar 25, 2010
Messages
2
Hi everyone, I don't have any experience with VBA but I need to use it on a payroll spreadsheet. What a need to do is have a button that saves R2:AA47 in the sheet called Payslips to a PDF on my desktop, I would also like to have the PDF named by the payslip number which is in cell Z6......is this possible by using a simple button? Any help would be greatly appreciated
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
.
VBA Code:
Option Explicit

Sub SveRngPDF()

Dim Today As Date
Sheets("Payslips").Range("R2:AA47").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\?????\Desktop\" & Sheets("Payslips").Range("Z6").Value & " ", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    
End Sub


See if the above works for your system. NOTE: change the path section ???? to your computer name.
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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