#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default printing

I need to be able to dynamically print rows where data exists within
Excel, however the following is causing me problems.

Basically "Doc Sheet 1", contains formulas which go from row 7 to 599.
If I try to print this when there is no data in there it then prints
out 600 lines worth of blank pages!

Therefore, following help from yourselves, this is now done using
offset function. The offset function works fine when column C
contains either a "Y" or "N", however I also need this to print out 1
page only (including the titles) if there is no Y's or N's.

Appreciate any advise on this - please let me know if you can help,
but need a copy of the spreadsheet and I will forward this on to you.

Many Thanks as always - Al Mackay ( )

Sub Print_Doc_Sheet_1()
'This sub prints the document control sheet 1

Sheets("Doc Sheet 1").Select
'Select Doc Sheet 1
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$6"
.PrintTitleColumns = "$B:$T"
End With
ActiveSheet.PageSetup.PrintArea = "Doc_Sheet_1"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("B7").Select

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default printing

Sub Print_Doc_Sheet_1()
'This sub prints the document control sheet 1

Sheets("Doc Sheet 1").Select
'Select Doc Sheet 1
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$6"
.PrintTitleColumns = "$B:$T"
End With
set rng = worksheets("Doc_Sheet_1").Range("B7:B600")
if application.Countif(rng,"Y")+application.Countif(r ng,"N") = 0 then
rng.Parent.Range("A1:J22").Printout ' adjust range to be 1 sheet
else
ActiveSheet.PageSetup.PrintArea = "Doc_Sheet_1"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("B7").Select
End if
End Sub

--
Regards,
Tom Ogilvy

"Al Mackay" wrote in message
om...
I need to be able to dynamically print rows where data exists within
Excel, however the following is causing me problems.

Basically "Doc Sheet 1", contains formulas which go from row 7 to 599.
If I try to print this when there is no data in there it then prints
out 600 lines worth of blank pages!

Therefore, following help from yourselves, this is now done using
offset function. The offset function works fine when column C
contains either a "Y" or "N", however I also need this to print out 1
page only (including the titles) if there is no Y's or N's.

Appreciate any advise on this - please let me know if you can help,
but need a copy of the spreadsheet and I will forward this on to you.

Many Thanks as always - Al Mackay ( )

Sub Print_Doc_Sheet_1()
'This sub prints the document control sheet 1

Sheets("Doc Sheet 1").Select
'Select Doc Sheet 1
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
ActiveWorkbook.Names.Add Name:="Doc_Sheet_1", RefersToR1C1:= _
"=OFFSET('Doc Sheet 1'!R7C2,0,0,COUNTIF('Doc Sheet
1'!R7C2:R600C2,""Y"")+COUNTIF('Doc Sheet 1'!R7C2:R600C2,""N""),19)"
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$6"
.PrintTitleColumns = "$B:$T"
End With
ActiveSheet.PageSetup.PrintArea = "Doc_Sheet_1"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("B7").Select

End Sub



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
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
Excel Printing --Borders are not printing on the same page as data Stup88 Excel Discussion (Misc queries) 1 August 7th 07 09:34 AM
Printing a heading on each new page when printing Brian Excel Discussion (Misc queries) 3 November 15th 06 05:22 PM
Printing Al Excel Worksheet Functions 2 December 14th 05 02:59 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM


All times are GMT +1. The time now is 05:38 PM.

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

About Us

"It's about Microsoft Excel"