View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JimMay JimMay is offline
external usenet poster
 
Posts: 28
Default Code assistance needed

So there's no way to Preview this before actually Printing it?
Appreciate you help;
Jim


"Haldun Alay" wrote in message
:

You need to replace printpreview with printout and use this macro instead of standard print command.

Because of page header and footer are static it is printing the pages one by one.

Code follows.

Sub PrintSubTotalInFooter()
Dim lrow As Long
Dim numhpb As Long
Dim LPage As Long
Dim i As Integer
Dim STRng As Range
Application.EnableEvents = False
' The PageSetUp Print Range has already been set to Range A5:F149
Set STRng = Application.InputBox( _
"Highlight the Range of Amts to be Subtotaled ", Type:=8)
rrows = Range(ActiveSheet.PageSetup.PrintTitleRows).Rows.C ount
With ActiveSheet
.PageSetup.RightFooter = ""
numhpb = .HPageBreaks.Count
LPage = numhpb + 1
For i = 1 To numhpb
.PageSetup.RightFooter = "Sub-total = " & Format( _
WorksheetFunction.Sum(Range(STRng(1).Address, _
STRng(.HPageBreaks(i).Location.Row - (1 + rrows)).Address)), _
"0,000.00")
On Error GoTo ErrorHandler
.PrintOut i, i
Next i
.PageSetup.RightFooter = "The-total = " & Format(WorksheetFunction.Sum( _
STRng), "0,000.00")
On Error GoTo ErrorHandler
.PrintOut LPage, LPage
End With
ErrorHandler:
Application.EnableEvents = True
End Sub




--
Haldun Alay