printing PDF'a with vba

Mr Integrity

New Member
Joined
Apr 19, 2018
Messages
4
Hello all

I have a file with about 100 different sheets. I need to be able to print individual pdf's of each sheet automatically. I currently use the following
Dim ws As Worksheet

For Each ws In Worksheets
ws.Select
nm = ws.Name

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\\Users\Daniel Bean\Desktop\CFO" & nm & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False

Next ws

End Sub

This works fine but the problem is that I do not want all sheets printed nor the same ones each time. How can I make a list to tell it which ones I want to print or even better how can I program it to print only sheets that a certain cell is > 0? Any help would be greatly appreciated.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi & welcome to MrExcel.
How about
Code:
For Each Ws In Worksheets
   If Ws.Range("A1").Value > 0 Then
      Nm = Ws.Name
      
      Ws.ExportAsFixedFormat Type:=xlTypePDF, _
         FileName:="C:\\Users\Daniel Bean\Desktop\CFO" & Nm & ".pdf", _
         Quality:=xlQualityStandard, IncludeDocProperties:=True, _
         IgnorePrintAreas:=False, OpenAfterPublish:=False
   End If
Next Ws
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Hello again
Well now I seem to have another problem. It does indeed print the sheets I want to separate pdf files, named the same as the sheet name. The problem is each pdf is not
actually that sheet. In other words every pdf regardless of name is the same. I have gone through and set print ranges for each individual sheet put it still prints only one
sheet just names it differently.
 
Upvote 0
It doesn't do that for me.
Are you sure you have
Code:
 [COLOR=#ff0000]Ws[/COLOR].ExportAsFixedFormat
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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
Back
Top