Totaling a column on each printed page

sobeitjedi

Board Regular
Joined
Mar 13, 2006
Messages
235
Office Version
  1. 365
Is there a way I can display the total of a column on each printed page?

I have a table which is about 6 columns long but is hundreds of rows down. I would like the total of one of these colums to be displayed on every printed page. Is this possible?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Assuming that you want the same grand total on each printed page...

Right click the Excel logo to the left of File on the menu bar, select View Code. Copy and paste in

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim Total
Total = Application.Sum(ActiveSheet.Range("A:A"))
ActiveSheet.PageSetup.CenterFooter = "Total of Column A = " & Total
End Sub

Change the references to column A to suit.
 
Upvote 0
Unfortunately not ... I want the total for that page to appear on each printed page.

Any more ideas?
 
Upvote 0
Try this - place the code in a regular module (ALT+F11, Insert Module).

Code:
Sub prttot()
Dim nPages As Integer, Lastrow As Long, RowsPerPage As Integer
Dim i As Long, StartRow As Long, EndRow As Long, Total
nPages = ExecuteExcel4Macro("GET.DOCUMENT(50)")
Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
RowsPerPage = ExecuteExcel4Macro("GET.DOCUMENT(64)") - 1
For i = 1 To nPages
    StartRow = 1 + RowsPerPage * (i - 1)
    EndRow = StartRow + RowsPerPage - 1
    If EndRow > Lastrow Then EndRow = Lastrow
    Total = Application.Sum(ActiveSheet.Range("A" & StartRow & ":A" & EndRow))
    Range("G" & EndRow).Value = "Total A = " & Total
Next i
ActiveSheet.PrintOut
For i = 1 To nPages
    StartRow = 1 + RowsPerPage * (i - 1)
    EndRow = StartRow + RowsPerPage - 1
    If EndRow > Lastrow Then EndRow = Lastrow
    Range("G" & EndRow).ClearContents
Next i
End Sub

Close the code window. Tools > Macro > Macros, click on prttot then click the run button. This should print your sheet with subtotals per page (for column A) in column G.
 
Upvote 0
I haven't tested the above, but I have four colums I want totalling - each total to appear under each column on the printed page. Is this asking too much of excel? Surely not?
 
Upvote 0
Is this asking too much of excel? Surely not?

As far as I am concerned - yes. Excel seems to have an inconsistent method of applying page breaks. If I could find that method I could insert blank rows then apply formulas. I have been singularly unsuccessful in doing this.

If you can make do with the totals appearing in columns to the right then my code can be modified relatively easily. Otherwise you need a guru.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top