Consulting

Results 1 to 4 of 4

Thread: Solved: Find Out what Page a cell will print on

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Location
    California
    Posts
    89
    Location

    Red face Find Out what Page a cell will print on

    Hi,

    What code would I use to find out what page a cell (using activecell) I have selected will print on?

    I have two sections of data and if the first part of the data doesn't go down to page two I don't need its headers. If it does I will need the headers so I need to know a way to determine when and if the first set of data goes to page two or greater.


    Thanks,
    Tasha
    Last edited by jazzyt2u; 12-09-2009 at 06:40 PM.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]
    Sub Check_PageBreak()
    Dim i As Integer, x as Integer, BreakType As Integer
    For i = 2 To ActiveCell.Row
    BreakType = Cells(i, 1).EntireRow.PageBreak
    If BreakType = xlAutomatic Or BreakType = xlManual Then x = x + 1
    Next
    MsgBox "your cell is on page " & x + 1
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Jun 2008
    Location
    California
    Posts
    89
    Location
    Thank you VERY much!!!!

  4. #4
    VBAX Regular
    Joined
    Jun 2008
    Location
    California
    Posts
    89
    Location
    Do you know how to find out what the first cell is on a new page?

Posting Permissions

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