ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell in Header ? (https://www.excelbanter.com/excel-programming/331901-cell-header.html)

Ronbmy

Cell in Header ?
 

I have been given a worksheet to print that will consist of 300 a4
pages.

What I would like to do is take the value of 2 cells from each page and
print them in the header for that page. This will allow a simple
indexing system without having to examine each page.

The pages are identical in layout and the same 2 cells will be used
from each page.

I have tried the standard 'cell in header' but that would print the
same info on every page. Is there a way to do this automatically?

I have never done macros in excel so all help will be appreciated.

Thanks

Ron.


--
Ronbmy
------------------------------------------------------------------------
Ronbmy's Profile: http://www.excelforum.com/member.php...o&userid=24164
View this thread: http://www.excelforum.com/showthread...hreadid=379477


Ron de Bruin

Cell in Header ?
 
Hi

Untested (No printer om my machine on this moment)

Try this example for pages below each other
Let me know if t is working correct

It will print the cell in A and C from the first row in each page in
the header.

Sub Test_For_Each_HPageBreak()
Dim HPB As HPageBreak
Dim RW As Long
Dim PageNum As Long
Dim Asheet As Worksheet

Set Asheet = ActiveSheet
RW = 1
PageNum = 1

If Asheet.HPageBreaks.Count = 0 Then
MsgBox "There are no HPageBreaks"
Exit Sub
End If

For Each HPB In Asheet.HPageBreaks

With Asheet.PageSetup
.RightHeader = Asheet.Cells(RW, "A") & " " & Asheet.Cells(RW, "C")
ActiveSheet.PrintOut From:=PageNum, To:=PageNum
End With

RW = HPB.Location.Row
PageNum = PageNum + 1
Next HPB

Asheet.DisplayPageBreaks = False
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ronbmy" wrote in message
...

I have been given a worksheet to print that will consist of 300 a4
pages.

What I would like to do is take the value of 2 cells from each page and
print them in the header for that page. This will allow a simple
indexing system without having to examine each page.

The pages are identical in layout and the same 2 cells will be used
from each page.

I have tried the standard 'cell in header' but that would print the
same info on every page. Is there a way to do this automatically?

I have never done macros in excel so all help will be appreciated.

Thanks

Ron.


--
Ronbmy
------------------------------------------------------------------------
Ronbmy's Profile: http://www.excelforum.com/member.php...o&userid=24164
View this thread: http://www.excelforum.com/showthread...hreadid=379477




Ronbmy[_2_]

Cell in Header ?
 

Hi Ron,

Many thanks for that - it works perfectly.

Ron.


--
Ronbmy
------------------------------------------------------------------------
Ronbmy's Profile: http://www.excelforum.com/member.php...o&userid=24164
View this thread: http://www.excelforum.com/showthread...hreadid=379477


Ron de Bruin

Cell in Header ?
 
Thanks for the feedback


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ronbmy" wrote in message
...

Hi Ron,

Many thanks for that - it works perfectly.

Ron.


--
Ronbmy
------------------------------------------------------------------------
Ronbmy's Profile: http://www.excelforum.com/member.php...o&userid=24164
View this thread: http://www.excelforum.com/showthread...hreadid=379477





All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com