Multiple Sheets to Individual PDFs

jessi8188

New Member
Joined
Aug 26, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi, I need to print multiple sheets from the same workbook to individual PDFs.

I need it to create a folder on the desktop if possible using cell A1 from the Master sheet which contains the date of payment.
For every sheet in the workbook I want it to save using Name of Sheet & Master!A1
I then want it to activate the Master sheet.

Everything I have tried so far just keeps giving me errors.

Sub ExportToPDFs()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Select
nm = ws.Name
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\xo-je\Documents\Fins\" & nm & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next ws
Sheets("master").Activate
End Sub
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,269
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Sub jessi()
   Dim Dte As String, Pth As String
   Dim Ws As Worksheet
   
   Dte = Format(Sheets("Master").Range("A1").Value, "dd_mm_yyyy")
   Pth = Environ("userprofile") & "\Desktop\" & Dte & "\"
   If Dir(Pth, vbDirectory) = "" Then
      MkDir Pth
   End If
   For Each Ws In Worksheets
      If LCase(Ws.Name) <> "master" Then
         Ws.ExportAsFixedFormat xlTypePDF, Pth & Ws.Name & " " & Dte & ".pdf", xlQualityStandard, True, False, , , False
      End If
   Next Ws
   Sheets("Master").Activate
End Sub
 

jessi8188

New Member
Joined
Aug 26, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Sub jessi()
   Dim Dte As String, Pth As String
   Dim Ws As Worksheet
  
   Dte = Format(Sheets("Master").Range("A1").Value, "dd_mm_yyyy")
   Pth = Environ("userprofile") & "\Desktop\" & Dte & "\"
   If Dir(Pth, vbDirectory) = "" Then
      MkDir Pth
   End If
   For Each Ws In Worksheets
      If LCase(Ws.Name) <> "master" Then
         Ws.ExportAsFixedFormat xlTypePDF, Pth & Ws.Name & " " & Dte & ".pdf", xlQualityStandard, True, False, , , False
      End If
   Next Ws
   Sheets("Master").Activate
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
53,269
Office Version
  1. 365
Platform
  1. Windows
You're welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,259
Messages
5,600,573
Members
414,389
Latest member
MarkElla

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top