Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Printing one or more pages?

I have a spreadsheet that pulls info into a report. This
report is
usually only a few lines long and prints onto one page of
paper
without any problem.

Sometimes however there is enough info to go over the
page.
Currently I have formula on each line of the report page
that gets the
info, if there is no info the line is left blank. Is
there any way to
fill the report down three or four pages with these
formula but only
print the one or two pages that have info or can anyone
suggest
another way of doing it.

Page one

Report Header
....
...

Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
..
..
..

Down to the full fourty lines of data for 1 page.
Sometimes I need forty five or sixty or seventy lines but
this will
print blank pages if I fill the formula down.

A VBA program would be acceptable if possible?

Any ideas?


Regards Dean

www.dkso.co.uk/ <http://www.dkso.co.uk/
http://homepage.ntlworld.com/dkso

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing one or more pages?

go to the VBE and in the project explorer, select ThisWorkbook entry for
your project. Double click on it to get to the thisworkbook module. Put in
code like this:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim rng As Range, i As Long, lastrow As Long
If ActiveSheet.Name = "Report" Then
Set rng = Cells(Rows.Count, 1).End(xlUp)
For i = rng.Row To 1 Step -1
If Cells(i, 1) < "" Then
lastrow = i
Exit For
End If
Next
ActiveSheet.PageSetup.PrintArea = _
Range(Cells(1, 1), Cells(lastrow, 10)).Address( _
External:=True)
End If
End Sub

adjust Report to reflect the name of your report sheet and 10 to reflect the
number of columns to print.
--
Regards,
Tom Ogilvy

"Dean Southgate" wrote in message
...
I have a spreadsheet that pulls info into a report. This
report is
usually only a few lines long and prints onto one page of
paper
without any problem.

Sometimes however there is enough info to go over the
page.
Currently I have formula on each line of the report page
that gets the
info, if there is no info the line is left blank. Is
there any way to
fill the report down three or four pages with these
formula but only
print the one or two pages that have info or can anyone
suggest
another way of doing it.

Page one

Report Header
...
..

Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
Line of formula, pulled from page two if there is data to
pull
.
.
.

Down to the full fourty lines of data for 1 page.
Sometimes I need forty five or sixty or seventy lines but
this will
print blank pages if I fill the formula down.

A VBA program would be acceptable if possible?

Any ideas?


Regards Dean

www.dkso.co.uk/ <http://www.dkso.co.uk/
http://homepage.ntlworld.com/dkso



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
printing on many pages Georgea Excel Discussion (Misc queries) 2 January 4th 08 09:16 PM
How do I delete pages in Excel? Keeps printing blank pages at end. Jojobean Charts and Charting in Excel 1 May 31st 07 07:37 AM
Printing 3 out of 4 pages Rich Gibbons Excel Discussion (Misc queries) 2 May 17th 06 12:09 PM
PRINTING PAGES Meg Setting up and Configuration of Excel 0 January 13th 05 07:31 PM


All times are GMT +1. The time now is 10:49 AM.

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"