I have got an excel sheet that is used to make invoices. Now, I want to export this as PDF and send it on outlook. I managed to create a code that works. The only part which I am not sure about is that there are some parts of the excel sheet that I don’t want to be saved into the PDF. I was wondering if anyone knows a way to do that? I guess it would have to do with changing the part of the code which I am attaching, but I’m not sure what.
Also, I tried just entering Range() after ActiveSheet and then manually input what I DO want. This worked but when saved as PDF, each range is in its own page
Create the PDF ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=OpenPDFAfterCreating
Sub toPDF() ' This will copy a specified range('s) from ws1 & ws2 to ws3. ' Now you can print ws3 to PDF with only the desired data. Dim ws1 As Worksheet Dim ws2 As Worksheet Dim ws3 As Worksheet Dim lRow1 As Integer Dim lRow2 As Integer Dim lRow3 As Integer Set ws1 = Worksheets("Sheet1") Set ws2 = Worksheets("Sheet2") Set ws3 = Worksheets("Sheet3") lRow1 = Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Row lRow2 = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row ws3.Activate ws3.Columns("A:G").Delete lRow3 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row ws1.Range("B3:H" & lRow1).Copy Destination:=ws3.Range("A" & lRow3) ' you can adjust your page1 range here lRow3 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row ws2.Range("B3:H" & lRow1).Copy Destination:=ws3.Range("A" & lRow3) ' you can adjust your page2 range here 'ActiveSheet.PrintOut ActivePrinter:="PDFCreator" ' (I use PDFCreator, its free or you can put your PDF code here) ActiveSheet.DisplayPageBreaks = False End Sub