Jumping To a Specific Page

Written by Allen Wyatt (last updated February 26, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003


1

Suppose that you have a large worksheet that requires 16 pages when printed out. You may wonder if there is a way, when working within the worksheet, to jump to some given page, such as page 5.

Word users know that they can, within Word, use the Go To dialog box to jump to various pages, but no such feature exists in Excel. There are a couple of ways you can approach the problem, however.

One approach is to select the cell that appears at the top of a page. (For instance, that cell that appears at the top-left of page 5.) You can then define a name for the cell, such as Page05. Do this for each page in your worksheet, and you can then use the features within Excel to jump to those names.

Another way you can do this is to use the page break preview mode. (To switch to page break preview, choose View | Page Break Preview.) You can then see where the page breaks are, select a cell on the page you want, and then return to normal view.

It is possible to also create a macro that will let you jump to a specific page, but it isn't as easy as you might think. The reason has to do with the possible use of hard page breaks, which can change where pages start and end. The following macro might do the trick for you, however. It prompts the user for a page number and then selects the top-left cell on the page entered.

Sub GotoPageBreak()
    Dim iPages As Integer
    Dim wks As Worksheet
    Dim iPage As Integer
    Dim iVertPgs As Integer
    Dim iHorPgs As Integer
    Dim iHP As Integer
    Dim iVP As Integer
    Dim iCol As Integer
    Dim lRow As Long
    Dim sPrtArea As String
    Dim sPrompt As String
    Dim sTitle As String

    Set wks = ActiveSheet
    iPages = ExecuteExcel4Macro("Get.Document(50)")
    iVertPgs = wks.VPageBreaks.Count + 1
    iHorPgs = wks.HPageBreaks.Count + 1
    sPrtArea = wks.PageSetup.PrintArea

    sPrompt = "Enter a page number (1 through "
    sPrompt = sPrompt & Trim(Str(iPages)) & ") "
    sTitle = "Enter Page Number"

    iPage = InputBox(Prompt:=sPrompt, Title:=sTitle)

    If wks.PageSetup.Order = xlDownThenOver Then
        iVP = Int((iPage - 1) / iHorPgs)
        iHP = ((iPage - 1) Mod iHorPgs)
    Else
        iHP = Int((iPage - 1) / iVertPgs)
        iVP = ((iPage - 1) Mod iVertPgs)
    End If

    If iVP = 0 Then
        If sPrtArea = "" Then
            iCol = 1
        Else
            iCol = wks.Range(sPrtArea).Cells(1).Column
        End If
    Else
        iCol = wks.VPageBreaks(iVP).Location.Column
    End If

    If iHP = 0 Then
        If sPrtArea = "" Then
            lRow = 1
        Else
            lRow = wks.Range(sPrtArea).Cells(1).Row
        End If
    Else
        lRow = wks.HPageBreaks(iHP).Location.Row
    End If

    wks.Cells(lRow, iCol).Select
    Set wks = Nothing
End Sub

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5823) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Setting Data Validation Input Messages

When using data validation, you might want to have Excel display a message when someone starts to enter information into ...

Discover More

Creating a Photo Catalog from a Folder of Photos

Excel is great for collecting all sorts of information. You might even use it to create a catalog of your photos. Working ...

Discover More

Pulling Access Information into Excel

If you have a lot of data stored in Access databases, you may want to get at that information using Excel. There are a ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Scrolling Up and Down

Need an easy way to move through a spreadsheet using a mouse? Here are a couple of ideas.

Discover More

Jumping to the Real Last Cell

Jumping to the last cell in a worksheet should be easy, but you may not always get the results that you expect. This tip ...

Discover More

Finding the End of the Worksheet

Want a quick way to get to the last cell in your worksheet? This tip provides a handy shortcut and a potential "gotcha."

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

2022-07-09 04:01:25

Two Nine Zero Seven

I really like this article, it is very useful and it is only the one that I'm looking for.

But is it possible to make the code is not run a dialoge box, I mean I want the code to run on the formula. For example I have page 2 that has the first cell started on cell A21, and then when I type GotoPageBreak(Page1) it well return as A21. I also want the similar thing is happen to the third page, which has the first cell started on A48, and then I only need to type GotoPageBreak(Page2) and then it will return to A48.

What should I do to make that possible, should I rewrite some part of the code? Or if you got a time write a VBA code that formula based like what I want.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.