+ Reply to Thread
Results 1 to 5 of 5

Cell in Header ?

  1. #1
    Registered User
    Join Date
    06-09-2005
    Posts
    2

    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.

  2. #2
    Ron de Bruin
    Guest

    Re: 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" <Ronbmy.1qoouc_1118865912.5896@excelforum-nospam.com> wrote in message
    news:Ronbmy.1qoouc_1118865912.5896@excelforum-nospam.com...
    >
    > 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
    >




  3. #3
    Registered User
    Join Date
    06-09-2005
    Posts
    2
    Hi Ron,

    Many thanks for that - it works perfectly.

    Ron.

  4. #4
    Ron de Bruin
    Guest

    Re: Cell in Header ?

    Thanks for the feedback


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


    "Ronbmy" <Ronbmy.1qqruf_1118963126.1527@excelforum-nospam.com> wrote in message
    news:Ronbmy.1qqruf_1118963126.1527@excelforum-nospam.com...
    >
    > 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
    >




  5. #5
    Ron de Bruin
    Guest

    Re: Cell in Header ?

    Hi Ronbmy

    There is bug that can be a problem.
    You must select a cell below your data to avoid a Error 9.

    See this page for as example how to do this
    http://www.rondebruin.nl/hpagebreaks.htm


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


    "Ronbmy" <Ronbmy.1qqruf_1118963126.1527@excelforum-nospam.com> wrote in message
    news:Ronbmy.1qqruf_1118963126.1527@excelforum-nospam.com...
    >
    > 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
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1