Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code shown below works "correctly" in printing the selected sheets.
However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Also, it is printing the sheet with all of the buttons and check boxes.
Is there a way to prevent it from printing that sheet? "Aaron" wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do a search on .PrintOut and see if there's something there you can use.
-- HTH, Barb Reinhardt "Aaron" wrote: Also, it is printing the sheet with all of the buttons and check boxes. Is there a way to prevent it from printing that sheet? "Aaron" wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Barb.
There is a post titled "CheckBox to select pages to print?" from 9/1/2007 It seems similar. Do you think that is the direction I should head? "Barb Reinhardt" wrote: Do a search on .PrintOut and see if there's something there you can use. -- HTH, Barb Reinhardt "Aaron" wrote: Also, it is printing the sheet with all of the buttons and check boxes. Is there a way to prevent it from printing that sheet? "Aaron" wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you use this one line:
Sheets(array("ClientData","W1","Fee")).PrintOut Do you get one file? And what happens if checkbox28 and checkbox31 are each checked? Your existing code would print the same sheet multiple times. Aaron wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ps.
If you only get one file, you can use this kind of code to build an array of names that should be printed: Option Explicit Private Sub PrintSelected_Click() Dim sCtr As Long Dim SheetNames() As String Dim wks As Worksheet Application.Dialogs(xlDialogPrint).Show sCtr = 0 If CheckBox1 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "Clientdata" End If If CheckBox2 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "w1" End If If CheckBox3 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "fee" End If 'I got bored here! If sCtr 0 Then Sheets(SheetNames).PrintOut preview:=True End If End Sub Dave Peterson wrote: If you use this one line: Sheets(array("ClientData","W1","Fee")).PrintOut Do you get one file? And what happens if checkbox28 and checkbox31 are each checked? Your existing code would print the same sheet multiple times. Aaron wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub -- Dave Peterson -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks! I will work on it. I understand the bordom I used Excel to write
the code the first time. "Dave Peterson" wrote: ps. If you only get one file, you can use this kind of code to build an array of names that should be printed: Option Explicit Private Sub PrintSelected_Click() Dim sCtr As Long Dim SheetNames() As String Dim wks As Worksheet Application.Dialogs(xlDialogPrint).Show sCtr = 0 If CheckBox1 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "Clientdata" End If If CheckBox2 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "w1" End If If CheckBox3 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "fee" End If 'I got bored here! If sCtr 0 Then Sheets(SheetNames).PrintOut preview:=True End If End Sub Dave Peterson wrote: If you use this one line: Sheets(array("ClientData","W1","Fee")).PrintOut Do you get one file? And what happens if checkbox28 and checkbox31 are each checked? Your existing code would print the same sheet multiple times. Aaron wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub -- Dave Peterson -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So I think I have it for the most part.
Most of the code is for printing the report or the proposal for some financial work I do. There are 2 sections in the original code I posted where it is selecting sheets to be printed for technical review based on the content of the sheets. These are to be printed in addition to default sheets to be printed. How do I revise this to your suggested code to get the correct effect? If CheckBox31 = True Then Sheets(Array("Summary", "ClientData", "W1", "Fee", "Data")).PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets(Array("Results", "bar", "pie", "Cash", "NPV", "Ex I")).PrintOut End If "Dave Peterson" wrote: ps. If you only get one file, you can use this kind of code to build an array of names that should be printed: Option Explicit Private Sub PrintSelected_Click() Dim sCtr As Long Dim SheetNames() As String Dim wks As Worksheet Application.Dialogs(xlDialogPrint).Show sCtr = 0 If CheckBox1 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "Clientdata" End If If CheckBox2 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "w1" End If If CheckBox3 = True Then sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = "fee" End If 'I got bored here! If sCtr 0 Then Sheets(SheetNames).PrintOut preview:=True End If End Sub Dave Peterson wrote: If you use this one line: Sheets(array("ClientData","W1","Fee")).PrintOut Do you get one file? And what happens if checkbox28 and checkbox31 are each checked? Your existing code would print the same sheet multiple times. Aaron wrote: The code shown below works "correctly" in printing the selected sheets. However, it is printing each sheet separately. i.e. when I print to PDF it produces multiple files instead of one file. Any suggestions for putting the output into one file? Your help is greatly appreciated! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut End If If CheckBox2 = True Then Sheets("W1").PrintOut End If If CheckBox3 = True Then Sheets("Fee").PrintOut End If If CheckBox4 = True Then Sheets("Data").PrintOut End If If CheckBox5 = True Then Sheets("B1").PrintOut End If If CheckBox6 = True Then Sheets("B2").PrintOut End If If CheckBox7 = True Then Sheets("B3").PrintOut End If If CheckBox8 = True Then Sheets("B4").PrintOut End If If CheckBox9 = True Then Sheets("B5").PrintOut End If If CheckBox10 = True Then Sheets("B6").PrintOut End If If CheckBox11 = True Then Sheets("B7").PrintOut End If If CheckBox12 = True Then Sheets("B8").PrintOut End If If CheckBox13 = True Then Sheets("B9").PrintOut End If If CheckBox14 = True Then Sheets("B10").PrintOut End If If CheckBox15 = True Then Sheets("B11").PrintOut End If If CheckBox16 = True Then Sheets("B12").PrintOut End If If CheckBox17 = True Then Sheets("B13").PrintOut End If If CheckBox18 = True Then Sheets("B14").PrintOut End If If CheckBox19 = True Then Sheets("B15").PrintOut End If If CheckBox20 = True Then Sheets("Combined").PrintOut End If If CheckBox21 = True Then Sheets("Summary").PrintOut End If If CheckBox22 = True Then Sheets("Results").PrintOut End If If CheckBox23 = True Then Sheets("Bar").PrintOut End If If CheckBox24 = True Then Sheets("Pie").PrintOut End If If CheckBox25 = True Then Sheets("Cash").PrintOut End If If CheckBox26 = True Then Sheets("NPV").PrintOut End If If CheckBox27 = True Then Sheets("EX I").PrintOut End If If CheckBox30 = True Then Sheets("Summary").PrintOut End If If CheckBox28 = True Then Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If If CheckBox29 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Visible = -1 Then If sh.Range("B71").Value < "" Then sh.PrintOut End If End If Next sh End If If CheckBox31 = True Then Sheets("Summary").PrintOut Sheets("ClientData").PrintOut Sheets("W1").PrintOut Sheets("Fee").PrintOut Sheets("Data").PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets("Results").PrintOut Sheets("bar").PrintOut Sheets("pie").PrintOut Sheets("Cash").PrintOut Sheets("NPV").PrintOut Sheets("Ex I").PrintOut End If End Sub -- Dave Peterson -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did you test that .printout line to see if you really got a single file. If you
got multiple files, then you're wasting your time with this approach! Since you're building an array of sheet names, you could check to see if the worksheet name is already in the array. Dim Res as variant 'you only need to declare wks once and you can reuse it in both loops 'you don't need sh or she dim wks as worksheet .....lots of code For Each wks In ThisWorkbook.Worksheets If wks.Visible = -1 Then If wks.Range("B71").Value < "" Then if sctr = 0 then 'no names in array yet, so just add it sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = wks.name else 'there are names in the array, so check to see if that one is 'is in the array res = application.match(wks.name, sheetnames,0) if isnumeric(res) then 'already there, so don't add it again else 'not there, so add it. sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = wks.name end if end if end if end if next wks and you'd still print with something like: If sCtr 0 Then Sheets(SheetNames).PrintOut preview:=True End If Aaron wrote: So I think I have it for the most part. Most of the code is for printing the report or the proposal for some financial work I do. There are 2 sections in the original code I posted where it is selecting sheets to be printed for technical review based on the content of the sheets. These are to be printed in addition to default sheets to be printed. How do I revise this to your suggested code to get the correct effect? If CheckBox31 = True Then Sheets(Array("Summary", "ClientData", "W1", "Fee", "Data")).PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets(Array("Results", "bar", "pie", "Cash", "NPV", "Ex I")).PrintOut End If <<snipped |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That code is great and it works but your code and your comments have made me
realize I need to change my approach. I need to change the code checking cell B71 to only check sheets "B1" through "B15". Also in the section of code you wrote on this how can I include some sheets that need printed by default. There are default sheets that should be printed in order both before and after the sheets being evaluated in for content in cell B71. Also, do you have any ideas on how to keep the sheet with all the check boxes from being printed. Thank you, Aaron "Dave Peterson" wrote: Did you test that .printout line to see if you really got a single file. If you got multiple files, then you're wasting your time with this approach! Since you're building an array of sheet names, you could check to see if the worksheet name is already in the array. Dim Res as variant 'you only need to declare wks once and you can reuse it in both loops 'you don't need sh or she dim wks as worksheet .....lots of code For Each wks In ThisWorkbook.Worksheets If wks.Visible = -1 Then If wks.Range("B71").Value < "" Then if sctr = 0 then 'no names in array yet, so just add it sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = wks.name else 'there are names in the array, so check to see if that one is 'is in the array res = application.match(wks.name, sheetnames,0) if isnumeric(res) then 'already there, so don't add it again else 'not there, so add it. sCtr = sCtr + 1 ReDim Preserve SheetNames(1 To sCtr) SheetNames(sCtr) = wks.name end if end if end if end if next wks and you'd still print with something like: If sCtr 0 Then Sheets(SheetNames).PrintOut preview:=True End If Aaron wrote: So I think I have it for the most part. Most of the code is for printing the report or the proposal for some financial work I do. There are 2 sections in the original code I posted where it is selecting sheets to be printed for technical review based on the content of the sheets. These are to be printed in addition to default sheets to be printed. How do I revise this to your suggested code to get the correct effect? If CheckBox31 = True Then Sheets(Array("Summary", "ClientData", "W1", "Fee", "Data")).PrintOut 'xlSheetVisible = -1 Dim she As Worksheet For Each she In ThisWorkbook.Worksheets If she.Visible = -1 Then If she.Range("B71").Value < "" Then she.PrintOut End If End If Next she Sheets(Array("Results", "bar", "pie", "Cash", "NPV", "Ex I")).PrintOut End If <<snipped |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can't check selection boxes | Excel Discussion (Misc queries) | |||
Copy and move check box (check boxes) with new cell link? | Excel Worksheet Functions | |||
How do I use check boxes to determine which worksheets to print? | Excel Programming | |||
Print = moving check boxes | Excel Discussion (Misc queries) | |||
Check boxes I have inserted in Excel move when I print? | Excel Discussion (Misc queries) |