Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Page Totals

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Print Page Totals

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Page Totals

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Page Totals

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.


"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Print Page Totals

There is no worksheet_beforeprint event.

And just make sure you only change the footer for the worksheet you want:

worksheets("somesheethere").PageSetup.RightFooter = "Page Amount = " & dblSum

I'd be careful and specify the sheet to get the dblSum from, too.

Doug F. wrote:

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.

"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Page Totals

Hi Dave,
Thanks for your notes. My last but perhaps biggest challenge is to get the
'dblSum' for the *page* being printed, as the single sheet when printed has
many pages. My fallback solution is a MS Access report linking to the xls.

--
Doug F.


"Dave Peterson" wrote:

There is no worksheet_beforeprint event.

And just make sure you only change the footer for the worksheet you want:

worksheets("somesheethere").PageSetup.RightFooter = "Page Amount = " & dblSum

I'd be careful and specify the sheet to get the dblSum from, too.

Doug F. wrote:

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.

"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Print Page Totals

There's nothing in excel that will tell you the name of the worksheet being
printed.

You can group multiple sheets and print those selected sheets.

You can print the entire workbook.

But you can just change the footer for each sheet and it won't matter if you're
printing it or not.

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
for each wks in me.worksheets
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
next wks
End Sub

This will blow up if there's any worksheet that doesn't have that range name
(Test). Could that happen?

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
dim TestRng as range

for each wks in me.worksheets

set testrng = nothing
on error resume next
set testrng = wks.range("Test")
on error goto 0

if testrng is nothing then
'do nothing, skip that footer
else
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
end if

next wks
End Sub

(Untested, uncompiled)

Doug F. wrote:

Hi Dave,
Thanks for your notes. My last but perhaps biggest challenge is to get the
'dblSum' for the *page* being printed, as the single sheet when printed has
many pages. My fallback solution is a MS Access report linking to the xls.

--
Doug F.

"Dave Peterson" wrote:

There is no worksheet_beforeprint event.

And just make sure you only change the footer for the worksheet you want:

worksheets("somesheethere").PageSetup.RightFooter = "Page Amount = " & dblSum

I'd be careful and specify the sheet to get the dblSum from, too.

Doug F. wrote:

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.

"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Page Totals

Thanks Dave, this will provide me a solution.

--
Doug F.


"Dave Peterson" wrote:

There's nothing in excel that will tell you the name of the worksheet being
printed.

You can group multiple sheets and print those selected sheets.

You can print the entire workbook.

But you can just change the footer for each sheet and it won't matter if you're
printing it or not.

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
for each wks in me.worksheets
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
next wks
End Sub

This will blow up if there's any worksheet that doesn't have that range name
(Test). Could that happen?

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
dim TestRng as range

for each wks in me.worksheets

set testrng = nothing
on error resume next
set testrng = wks.range("Test")
on error goto 0

if testrng is nothing then
'do nothing, skip that footer
else
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
end if

next wks
End Sub

(Untested, uncompiled)

Doug F. wrote:

Hi Dave,
Thanks for your notes. My last but perhaps biggest challenge is to get the
'dblSum' for the *page* being printed, as the single sheet when printed has
many pages. My fallback solution is a MS Access report linking to the xls.

--
Doug F.

"Dave Peterson" wrote:

There is no worksheet_beforeprint event.

And just make sure you only change the footer for the worksheet you want:

worksheets("somesheethere").PageSetup.RightFooter = "Page Amount = " & dblSum

I'd be careful and specify the sheet to get the dblSum from, too.

Doug F. wrote:

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.

"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.

--

Dave Peterson


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Print Page Totals

Doug, here's another way around it; it's kind of complicated, but it should
work. I'm going to use an example of only one sheet. Here are the logical
steps
-Find the PrintArea of the sheet
-Find all pagebreaks (manual & automatic) - it will make your life much
easier if you can make the simplifying assumption that all breaks are
horizontal (pages only go down the worksheet, not down and accross)
-From the pagebreaks, you will know the total page count (for a "Page x of
Y" footer)
-Determine the addresses for all the individual printed sheets - we'll call
these Print Area Pages
-For each Print Area Page, calculate the sum, modify the PageSetup, print

If you decide to go this route, I can share the code that identifies the
Print Area Pages.

Bill



"Doug F." wrote:

Thanks Dave, this will provide me a solution.

--
Doug F.


"Dave Peterson" wrote:

There's nothing in excel that will tell you the name of the worksheet being
printed.

You can group multiple sheets and print those selected sheets.

You can print the entire workbook.

But you can just change the footer for each sheet and it won't matter if you're
printing it or not.

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
for each wks in me.worksheets
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
next wks
End Sub

This will blow up if there's any worksheet that doesn't have that range name
(Test). Could that happen?

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
dim wks as worksheet
dim TestRng as range

for each wks in me.worksheets

set testrng = nothing
on error resume next
set testrng = wks.range("Test")
on error goto 0

if testrng is nothing then
'do nothing, skip that footer
else
wks.pageSetup.RightFooter = "Page Amount = " _
& application.sum(wks.range("test"))
end if

next wks
End Sub

(Untested, uncompiled)

Doug F. wrote:

Hi Dave,
Thanks for your notes. My last but perhaps biggest challenge is to get the
'dblSum' for the *page* being printed, as the single sheet when printed has
many pages. My fallback solution is a MS Access report linking to the xls.

--
Doug F.

"Dave Peterson" wrote:

There is no worksheet_beforeprint event.

And just make sure you only change the footer for the worksheet you want:

worksheets("somesheethere").PageSetup.RightFooter = "Page Amount = " & dblSum

I'd be careful and specify the sheet to get the dblSum from, too.

Doug F. wrote:

A followup.
If I have this code in the Worksheet_BeforePrint it doesn't show anything in
the footer, when it's in the Workbook_BeforePrint it does show in the footer
a sum but of the entire worksheet not just the page being printed. So, the
questions are, which event should I be using and can I restrict the range to
the printed page?

Thanks,
--
Doug F.

"Doug F." wrote:

Thanks Bill.
--
Doug F.


"Bill Pfister" wrote:

Here is a psuedocode approach. Your only issue will be determining the
proper range, but this is not a terribly difficult task.

set rngTest = ' here you need to specify the range that you want to sum that
is
' visible on this particular printed page
dblSum = Application.WorksheetFunction.Sum( rngTest )
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & dblSum


Regards,
Bill



"Doug F." wrote:

On each page printed I want to sum a column on that page and print that total
on the bottom of that page, probably in the footer (ie a total amount for a
data entry balancing process performed elsewhere). Each page has its own
total it's not a running total. I've tried variations of the following where
'test' is a named column label:

Public Sub Worksheet_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = "Page Amount = " & Sum([test])
End Sub

It doesn't like the Sum function in this event.

Ideas? Thanks,
--
Doug F.

--

Dave Peterson


--

Dave Peterson

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
stop page totals creeping up page when scrolling VB Excel Discussion (Misc queries) 0 March 24th 09 11:28 PM
Setting the print area in page set up to print 1 page wide by 2 pages tall EA[_2_] Excel Discussion (Misc queries) 2 July 12th 07 08:39 PM
HOW DO I SETUP A PAGE IN EXCEL TO GIVE TOTALS TO ANOTHER PAGE Randy Excel Worksheet Functions 1 February 8th 07 06:15 PM
print footer on every page (Totals on every page) sweetyoli Excel Discussion (Misc queries) 1 January 3rd 07 09:26 PM
tOTALS WON'T PRINT ON SAME PAGE annes519 New Users to Excel 2 June 3rd 05 11:12 PM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"