Creating Individual PDFs by Worksheet

Written by Allen Wyatt (last updated November 18, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


5

Lissa has a workbook that contains multiple worksheets. She would like to create individual PDFs for these worksheets (one PDF per worksheet) with the name of the PDF based on the worksheet's name. She wonders if there is a way to do this in Excel.

There are ways to do it, depending on how much time you want to spend. If this is a "one off" occurrence, you might consider just printing each individual worksheet manually. Or, you could copy each worksheet to its own workbook and then print each workbook to PDF.

These are quite manually intensive, though. (Which is why I said they may be good for only "one off" occurrences.) If you would like something a bit more automatic, you'll want to turn to using a macro to do the PDF files. Here's an example of a short macro that will do the PDF creation for you:

Sub CreatePDFs()
    Dim wks As Worksheet
    Dim sFolder As String
    Dim sTemp As String

    sFolder = ActiveWorkbook.Path & "\"

    sTemp = "Created PDFs for the following worksheets"
    For Each wks In ActiveWorkbook.Worksheets
        If wks.Visible = xlSheetVisible Then
            sTemp = sTemp & vbCrLf & "   * " & wks.Name
            wks.ExportAsFixedFormat Type:=xlTypePDF, _
              Filename:=sFolder & wks.Name & ".pdf", _
              OpenAfterPublish:=False
        End If
    Next

    MsgBox sTemp
End Sub

Note that the path stored in the sFolder variable is set to whatever path is associated with the active workbook. (If you haven't saved the active workbook yet, then the macro will not run properly.) This path is the folder in which the PDF files are saved. If you want them saved in a different location, just change the value assigned to the sFolder variable.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13570) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Line Breaks After a Slash

Some writers use the slash to combine words and as shorthand to signify "or" or "and." This, of course, makes for some ...

Discover More

Double Indenting

Indenting a paragraph is easy in Word. In fact, the program provides shortcut keys that make it a snap. Indenting from ...

Discover More

Using the Format Painter with Editing Restrictions in Place

Word allows you to apply protection to your documents that can affect which tools users can access. If you want to exempt ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Printing Selected Cells by Default

Want a one-button approach to printing? Excel provides the Quick Print tool, but it may not do exactly what you want. ...

Discover More

Hiding a Hyperlink on a Printout

Hyperlinks can be real handy in a workbook, but you may not always want them visible when you send the workbook to the ...

Discover More

Changing Orientations within a Single Printout

Excel allows you to print out information in either portrait or landscape orientation, but what if you need both types of ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 9?

2018-10-23 15:50:33

Lissa

Thank you! That worked for me too!

I did try the macro once, but had that error as well and I haven't had a chance to comment and get a fix for it, until checking in today.

Lissa (original macro request submittal)


2018-10-10 10:29:01

Gary Lundblad

MF, that worked perfectly- thank you!!!

Gary


2018-10-09 23:50:12

MF

Filename:=sFolder & wks.Name & ".pdf", _

Hi Gary,
Try to change the last "full stop" to "comma" as above.
Regards,
MF


2018-10-09 16:28:36

Gary Lundblad

Thank you for the macro, but I receive a "Compile Error" on this portion of the code, which appeared red immediately after pasting it in. Any thoughts?
"wks.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=sFolder & wks.Name & ".pdf". _
OpenAfterPublish:=False"

Thank you!

Gary


2018-10-09 11:03:29

Gary Lundblad

Thank you for the macro, but I receive a "Compile Error" on this portion of the code, which appeared red immediately after pasting it in. Any thoughts?
"wks.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=sFolder & wks.Name & ".pdf". _
OpenAfterPublish:=False"

Thank you!

Gary


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.