Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Help to amend code which prints only certain sheets

Hi I have the code below linked to a form button , Basically the page "Sheet
1" always prints, and sheet 2 and 3 only print if the cells they look at are
true, which in turn are linked by form check boxes!


'To decide what pages get printed when used with print button
Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If

Sheets("Sheet3").Select
If Range("Calcs!f1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
End Sub


On sheet three is it possible to amend the code so that it looks at three
cells to see if they are true!

I would like it so that if "Calcs!f1" is true only the range A1:L8 prints
If "Calcs!f2" is true only the range A1:L16 prints
and If "Calcs!f3" is true the range A1:L30 prints.

Thanks for any advice.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Help to amend code which prints only certain sheets

Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
Sheets("Sheet").Select
If Range("Calcs!f1") = True and Range("Calcs!f2") < True and
Range("Calcs!f3") < True Then
Range("A1:L8").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$8"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
else
if Range("Calcs!f1") < True and Range("Calcs!f2") = True and
Range("Calcs!f3") < True Then
Range("A1:L16").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$16"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
else
if Range("Calcs!f1") <True and Range("Calcs!f2") < True and
Range("Calcs!f3") = True Then
Range("A1:L30").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$30"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
end if
end if
End Sub

Corey....

"Newbeetle" wrote in message
...
Hi I have the code below linked to a form button , Basically the page
"Sheet
1" always prints, and sheet 2 and 3 only print if the cells they look at
are
true, which in turn are linked by form check boxes!


'To decide what pages get printed when used with print button
Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If

Sheets("Sheet3").Select
If Range("Calcs!f1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
End Sub


On sheet three is it possible to amend the code so that it looks at three
cells to see if they are true!

I would like it so that if "Calcs!f1" is true only the range A1:L8 prints
If "Calcs!f2" is true only the range A1:L16 prints
and If "Calcs!f3" is true the range A1:L30 prints.

Thanks for any advice.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Help to amend code which prints only certain sheets

Sounds like you actually need radio buttons instead of check boxes. You can
still check the value (still boolean, true/false) and run as such, but
grouped together there can only be one selection. With the check boxes
there can be any [limited] number of choices.

HTH
Zack Barresse, aka firefytr


"Newbeetle" wrote in message
...
Hi I have the code below linked to a form button , Basically the page
"Sheet
1" always prints, and sheet 2 and 3 only print if the cells they look at
are
true, which in turn are linked by form check boxes!


'To decide what pages get printed when used with print button
Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If

Sheets("Sheet3").Select
If Range("Calcs!f1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
End Sub


On sheet three is it possible to amend the code so that it looks at three
cells to see if they are true!

I would like it so that if "Calcs!f1" is true only the range A1:L8 prints
If "Calcs!f2" is true only the range A1:L16 prints
and If "Calcs!f3" is true the range A1:L30 prints.

Thanks for any advice.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Help to amend code which prints only certain sheets

Thankyou very much, works a treat!!

"Corey" wrote:

Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
Sheets("Sheet").Select
If Range("Calcs!f1") = True and Range("Calcs!f2") < True and
Range("Calcs!f3") < True Then
Range("A1:L8").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$8"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
else
if Range("Calcs!f1") < True and Range("Calcs!f2") = True and
Range("Calcs!f3") < True Then
Range("A1:L16").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$16"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
else
if Range("Calcs!f1") <True and Range("Calcs!f2") < True and
Range("Calcs!f3") = True Then
Range("A1:L30").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$30"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
end if
end if
End Sub

Corey....

"Newbeetle" wrote in message
...
Hi I have the code below linked to a form button , Basically the page
"Sheet
1" always prints, and sheet 2 and 3 only print if the cells they look at
are
true, which in turn are linked by form check boxes!


'To decide what pages get printed when used with print button
Sub PrintButton_Click()
Sheets("Sheet1").Select
Application.Dialogs(xlDialogPrint).Show

'Water audit sheets to print
Sheets("Sheet2").Select
If Range("Calcs!i1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If

Sheets("Sheet3").Select
If Range("Calcs!f1") = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End If
End Sub


On sheet three is it possible to amend the code so that it looks at three
cells to see if they are true!

I would like it so that if "Calcs!f1" is true only the range A1:L8 prints
If "Calcs!f2" is true only the range A1:L16 prints
and If "Calcs!f3" is true the range A1:L30 prints.

Thanks for any advice.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
amend a VB code please Morgan Excel Discussion (Misc queries) 0 March 3rd 10 11:17 PM
Amend the Code shan_in_dubai Excel Programming 1 July 19th 05 09:36 AM
Amend code gavmer[_75_] Excel Programming 1 September 22nd 04 12:57 AM
Amend open Workbook code Stuart[_5_] Excel Programming 3 February 7th 04 04:55 PM
Amend code or change it completely? Gareth[_3_] Excel Programming 2 December 1st 03 07:24 PM


All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"