Hi,

I am trying to export various print area's to 1 pdf file,

I have the following code but it prints the whole workbook

Sub append()

Dim str As String, myfolder As String, myfile As String


str = "Do you want to save these sheets to a single pdf file?" & Chr(10)
For Each sht In ActiveWindow.SelectedSheets
    str = str & sht.Name & Chr(10)
Next sht

answer = MsgBox(str, vbYesNo, "Continue with save?")
If answer = vbNo Then Exit Sub

'Ask for a directory
With Application.FileDialog(msoFileDialogFolderPicker)
    .Show
    myfolder = .SelectedItems(1) & "\"
End With

'Ask for a file name
myfile = InputBox("Enter file name", "Save as..")

Set pa1 = Sheet7


 pa1.PageSetup.PrintArea = pa1.Range("B2:T44").Address
 
 

If Sheet7.Range("H8") = "123" Then

 Set pa2 = Sheet3
 
 pa2.PageSetup.PrintArea = pa2.Range("A1:T162").Address 

else
 
If Sheet7.Range("H8") = "456" Then

 Set pa2 = Sheet5
 
 pa2.PageSetup.PrintArea = pa2.Range("A1:T162").Address 

 End If
 


'Save sheets to pdf file
ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=myfolder & myfile _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

End Sub