PDA

View Full Version : [SOLVED] Footers question in VBA



Jayfunk
02-18-2014, 04:32 AM
Hello Guys,

I am currently working on a project at work to automate a report from data, i can do every page fine, some parts have one page and some parts have more than one page.

My problem is simple on all singe pages i have one green line above the footer on the cells above it to match what the old report had which is what i am going for. this green line nicely started the footer

Now on the parts with more than one page i can do this manually but i would like it automated the problem lies with finding the cell above the footer on each page.

does anyone one know how to do this or another way of doing the same thing

Many thanks

Jason

ashleyuk1984
02-18-2014, 07:47 AM
This might help you get started.


Sub CheckForPageBreaks()
Dim i As Integer

For i = 1 to ActiveSheet.UsedRange.Rows.Count
If Rows(i).PageBreak = xlManual then
MsgBox "There is a manual page break above row " & i
ElseIf Rows(i).PageBreak = xlAutomatic Then
MsgBox "There is an automatic page break above row " & i
End If
Next
End Sub
http://ultraimg.com/images/FJAkd.png

Change the code to insert a green line as required instead of create a msgbox. Can't program it at the moment, as I'm at work... But this should be somewhat helpful to start you off.