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
 

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,863
.
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.
 

buffalobill

New Member
Joined
Mar 25, 2010
Messages
2
WOW Logit, you are a legend, that works perfectly. Cant thank you enough. Much appreciated!
 

Watch MrExcel Video

Forum statistics

Threads
1,123,341
Messages
5,601,047
Members
414,424
Latest member
WillM69

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