Save certain sheets into one pdf using user forms

VTEXCEL

New Member
Joined
Jun 11, 2015
Messages
2
I am not very good with VBA, but I can edit some code. I need a code that allows users to select certain sheets to save into one pdf file. Preferably there would be a sheet with a bunch of check boxes with each sheet name next to it and then a button to compile all selected sheets into one pdf.

Thanks in advance!

Josh
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,951
this uses a list on main page...put X in col 1 to print, col 2 has the sheet name.
Code:
Sub PrintSelectSheets()
Dim sSht As String
Dim i As Integer
Dim col As New Collection

 'scan and collect the list of checked sheets
Range("B2").Select
While ActiveCell.Value <> ""
  If ActiveCell.Offset(0, -1).Value = "X" Then
    col.Add ActiveCell.Value
  End If
  
  ActiveCell.Offset(1, 0).Select
Wend

   'select the sheets to print
For i = 1 To col.Count
   Sheets(col(i)).Select (False)
Next

  'print to pdf printer
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
Set col = Nothing        'destroy collection

End Sub
 

VTEXCEL

New Member
Joined
Jun 11, 2015
Messages
2
Thanks ranman256, but it also prints out sheet 1. How do I exclude sheet1?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,213
Messages
5,594,868
Members
413,945
Latest member
V51773

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