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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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
 
Upvote 0

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

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