

Title:="Select Folder and FileName to save") StrFile = strName & "_" & strTime & ".pdf"įileFilter:="PDF Files (*.pdf), *.pdf", _ 'replace spaces and periods in sheet name StrTime = Format(Now(), "yyyymmdd\_hhmm") To use these macros in multiple Excel workbooks, save the code in a workbook that is always open, such as the Personal Workbook.To open the VBE, use the keyboard shortcut - Alt + F11.Create PDF file with name from worksheet cells - check for existing file, prompt to overwrite or choose different nameĬopy the following VBA code to a regular code module in the Visual Basic Editor (VBE), then select the sheet(s) you want to export, and run the macro.Create PDF file with name from worksheet cells - automatically overwrites existing file, if any.NOTE: There are two additional macros below: See the section further down, for details on how the macro works. Copy the code to a regular code module, then select the sheet(s) you want to export, and run the macro. The following macro code will export the active sheet (or selected sheets) in PDF format.

The best way to see how to change the code, so that it uses your prefernces, is to record an Excel macro, while you export an Excel sheet in PDF format.įirst, open a new Excel file, and type a few numbers, or some text, on Sheet 1 In the macros below, the code had settings for the PDF files that are created form the Excel sheets.

More Tutorials Export Sheet to PDF Settings
