The code below will export worksheets as PDFs. However, each worksheet has formulas that result in many blank rows. These blank rows are also in the PDFs which adds several blank pages.
Is there a way to only include the rows that have data in the PDF output for each worksheet?
Also, is it possible to automatically adjust the column widths and fit them all on one page horizontally?
Is there a way to only include the rows that have data in the PDF output for each worksheet?
Also, is it possible to automatically adjust the column widths and fit them all on one page horizontally?
VBA Code:
Sub LoopSheetsSaveAsPDF()
'Create variables
Dim ws As Worksheet
'Loop through all worksheets and save as individual PDF in same folder
'as the Excel file
For Each ws In ActiveWorkbook.Worksheets
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & ws.Name & ".pdf"
Next
End Sub