Save Range as PDF and Merge with another PDF in the output File


I would highly appreciate if you help me to make VBA that saves Sheet2 as PDF and  name it based on the data in Column B in Sheet1. Column B has many values, and I want to export number of Sheet2 same as number of Column B values.

The second thing, I want the exported pages to go to the directory file and every page merges  with PDF file that has the same name of Column C in Sheet1.


Thanks in advance

Top Contributor Asked on August 5, 2018 in VBA: Macros.
Add Comment
1 Answer(s)
Best answer

Hello Ready2go

This may only answer some of your question.

  1. The macro below will create a PDF file of Sheet2. The name of the pdf file will be from Sheet1 Cell B1. The PDF file will be saved to the root path of the open workbook.
  2. As for your second question, I can’t answer using VBA. However you can download a program call “PDFCreator” It is free to download and it can combine multiple pdf file into one.
Sub printws2As_PDF()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim sPath As String
Dim Fname As String
Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
sPath = ActiveWorkbook.Path
Fname = ws1.[B1]
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
sPath & "\" & Fname & ".PDF", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
End Sub
Expert Answered on August 12, 2018.

Mr. Hyside2,

I really thank your help and your continued support.

on August 17, 2018.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.