Hi all!
I have this problem trying to print multiple sheets in a single pdf. Browsing online and in the forum i found this code but when i use it i get the ERROR 9 "Subscript out of range" and i dont understand why. I tried in a new workbook the code and it works properly. Can someone help me?
Private Sub cmd_PrintPDF_Click()
ThisWorkbook.Sheets(Array("Costs", "Cars")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "/" & "Cost&Car", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
I have this problem trying to print multiple sheets in a single pdf. Browsing online and in the forum i found this code but when i use it i get the ERROR 9 "Subscript out of range" and i dont understand why. I tried in a new workbook the code and it works properly. Can someone help me?

Private Sub cmd_PrintPDF_Click()
ThisWorkbook.Sheets(Array("Costs", "Cars")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "/" & "Cost&Car", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub