PDA

View Full Version : formula in the end of the page



yahiaoui
10-22-2011, 06:18 AM
hi
How do I put a formula in the end of the page
When I have several pages
Of course, the use of vba
Thanks in advance

MCraiss
10-22-2011, 02:03 PM
What do you mean with 'end of page'?
First empty cell below a filled cell range?
The cell you rech by pressing <CTRL> <END>?

Please give details.

yahiaoui
10-23-2011, 08:48 AM
I hope to help

And may be annexed to a file

mdmackillop
10-23-2011, 09:07 AM
Such footers are tricky and best avoided! Page lengths can change for each printer.

Give this a try
Option Explicit

Sub Footers()
Dim i As Long, Br As Long, Rw As Long
Dim ws As Worksheet
Dim arr()

Set ws = ActiveSheet

Br = ws.HPageBreaks.Count
ReDim arr(Br)
arr(0) = 0
For i = 1 To Br
arr(i) = ws.HPageBreaks(i).Location.Row - 1
Cells(arr(i), 4).FormulaR1C1 = "=SUM(R" & arr(i - 1) + 1 & "C2:R" & arr(i) & "C2)"
Next
Rw = Cells(Rows.Count, 2).End(xlUp).Row
Cells(Rw, 4).FormulaR1C1 = "=SUM(R" & arr(Br) + 1 & "C2:R" & Rw & "C2)"

End Sub

yahiaoui
10-23-2011, 10:09 AM
Thank you very much
If allowed more explanation
For I Sastamlh in other equations

yahiaoui
10-23-2011, 10:16 AM
Is it possible to write the word "Total" Compared to the formula

mdmackillop
10-23-2011, 10:31 AM
Yes. Just add it in quotes with & to join it as you would normally do.

yahiaoui
10-23-2011, 12:07 PM
Thank you very much