one PDF file with multiple sheet

Ranju78

New Member
Joined
Apr 27, 2018
Messages
15
Hi ,
I want to write the VBA code which can generate one pdf file with multiple sheet with specific range.
I have excel file with 3 sheets: Accounting ,Management and invoice.
I want generate pdf file which has data from Accounting from range A2:I43, from Management from range A1:H25 and from Invoice from range B6:J46.

Please help.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
With the macro recorder running, try adding a new sheet, copy the 3 ranges to it, save the sheet as a PDF, then delete the sheet. The code can then be tweaked if needed, e.g. to specify a different file name.
 
Upvote 0
Hi John ,
Thanks you for the quick response. If you can make me more clear about it with VBA code. That will be appreciated..
Thank you.
 
Upvote 0
I am very new for VBA code. I could not find where i missed the code. Here is the code

Sub SaveAccountManagemenInvoicetInPDF()
If Worksheet = "Accounting" Then
If Worksheet.Range("H3") <> "" Then
Worksheet.PageSetup.PrintArea = "$A$2:$I$43"


ElseIf Worksheet = "Management" Then
Worksheet.PageSetup.PrintArea = "$A$1:$H$25"

ElseIf Worksheet = "Invoice" Then
Worksheet.PageSetup.PrintArea = "$B$6:$J$46"



End If




CurrentPath = ThisWorkbook.Path
PDFName = "H3"
PDFName = Replace(PDFName, "/", "")
PDFName = Replace(PDFName, "", "")
ThisWorkbook.Sheets(Array("Accounting", "Management","Invoice")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurrentPath & "" & PDFName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Else

MsgBox ("This macro shall only be excuted on Accounting tab")

Worksheet("Accounting").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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