PRINTOUT pages selected on a userform in either a3/a4 and printarea variable??

oldmanwilly

Board Regular
Joined
Feb 24, 2016
Messages
221
Hi

I have a userform with 10 checkboxes, and I want the user to be able to select a box and then either click a button that says a4 or a3 and once clicked will print the selected checkboxes (which correspond to sheet tabs) in a4 or a3 and the printarea will resize based on what they enter in the tables in the sheets.

I tried this code and used a named range for each sheet to count the last row in the sheets for the printarea.

any other information you need let me know thanks again.

Code:
Private Sub CommandButton1_Click()
Dim page1 As Sheets
Dim page2 As Sheets
Dim page3 As Sheets
Dim page4 As Sheets
Dim page5 As Sheets
Dim page6 As Sheets
Dim page7 As Sheets
Dim page8 As Sheets
Dim page9 As Sheets
Dim page10 As Sheets
Dim pageIndexbox As Sheets
Dim pageStartbox As Sheets
Dim pageIntroductionBox As Sheets
Dim pageguidancebox As Sheets
Dim pageDatainputtemplateBox As Sheets
Dim pageSummary1Box As Sheets
Dim pageSummary2Box As Sheets
Dim pageSummary3box As Sheets
Dim pagelistofmetricsBox As Sheets
Set page1 = Sheets("Index")
Set page2 = Sheets("Start")
Set page3 = Sheets("Introduction")
Set page4 = Sheets("Guidance")
Set page5 = Sheets("dATA INPUT TEMPLATE")
Set page6 = Sheets("Summary 1")
Set page7 = Sheets("Summary 2")
Set page8 = Sheets("Summary 3")
Set page9 = Sheets("List of Metrics")
'Set page10 = Sheets("Metadata")
pageIndexbox = page1
pageStartbox = page2
pageIntroductionBox = page3
pageguidancebox = page4
pageDatainputtemplateBox = page5
pageSummary1Box = page6
pageSummary2Box = page7
pageSummary3box = page8
pagelistofmetricsBox = page9

For Each CheckBox In UserForm1
    where CheckBox.Value = True
        Sheets("page" & CheckBox.Name).Activate
        Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintArea = ActiveSheet.Name & 1
        .FitToPagesWide = 1
        .FitToPagesTall = False
    End With
    Application.PrintCommunication = True
        ActiveSheet.PageSetup.PaperSize = xlPaperA4
        ActiveSheet.PrintOut
    Next
Next checkboxbox

code for print area

Code:
=OFFSET(INDEX!A1,0,0,COUNTA(INDEX!A:A)-1,COUNTA(INDEX!1:1))
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,377
Messages
6,119,185
Members
448,872
Latest member
lcaw

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