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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
2,172
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?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,155
Messages
5,835,697
Members
430,379
Latest member
QCLAN

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