J
JimMay
I've just come across this code in my archives, and it isn't
Working. It might be full of errors, but can someone assist is
Getting it on its feet?
Thanks in Advance.
Jim
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.Count
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
.PrintPreview i, i
Next i
.PageSetup.RightFooter = "The-total = " &
Format(WorksheetFunction.Sum _
(STRng), "0,000.00")
On Error GoTo ErrorHandler
.PrintPreview LPage, LPage
End With
ErrorHandler:
Application.EnableEvents = True
End Sub
Working. It might be full of errors, but can someone assist is
Getting it on its feet?
Thanks in Advance.
Jim
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.Count
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
.PrintPreview i, i
Next i
.PageSetup.RightFooter = "The-total = " &
Format(WorksheetFunction.Sum _
(STRng), "0,000.00")
On Error GoTo ErrorHandler
.PrintPreview LPage, LPage
End With
ErrorHandler:
Application.EnableEvents = True
End Sub