PDA

View Full Version : [SOLVED] Adding a Column Total to a Printed Report



jchapman1964
05-24-2005, 03:43 AM
Hi All:

I have a fairly basic spreadsheet which is intended to track time spent on a particular project (in days).

When printing a worksheet in this book, I want to be able to print a sum of a column at the end of the report...

Can somebody asisst with this?

Yours hopefully,



John

Bob Phillips
05-24-2005, 05:57 AM
I have a fairly basic spreadsheet which is intended to track time spent on a particular project (in days).

When printing a worksheet in this book, I want to be able to print a sum of a columnat the end of the report...

Could you not just add a sum formula in the worksheet?

jchapman1964
05-24-2005, 06:19 AM
Thanks for the reply!

I am sure that is what I need to do, but how do I get this to happen when I click on print? It needs to be done ideally so that a sum of a column is placed in the footer? understand this can be done through VBA but not being an expert.......??

J

Bob Phillips
05-24-2005, 06:40 AM
I am sure that is what I need to do, but how do I get this to happen when I click on print? It needs to be done ideally so that a sum of a column is placed in the footer? understand this can be done through VBA but not being an expert.......??J

I meant add it to the worksheet... but if you want it in the footer, then try


Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
If .Name = "Sheet1" Then
.PageSetup.LeftFooter = "Total = " & _
Application.Sum(Range("A:A"))
End If
End With
End Sub

This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet (or next to the File menu if you maximise your workbooks), select View Code from the menu, and paste the code

jchapman1964
05-24-2005, 07:27 AM
Thats Great!

Many thanks.....