Add a PageBreak into Excel

Posted on 2006-03-31
Last Modified: 2008-09-04
Hi All,

This should be an easy one.  I am trying to add a Pagebreak into an Excel sheet, and for the life of me I can't figure out how to do it.  I am able to create the sheet and add all of my data, but I cannot get the pagebreak to work.

Can someone show me how to add a pagebreak?

VB.Net 2003
Excel 2002


Question by:RichW
    LVL 4

    Accepted Solution


    in excel vba (99% similar in

    'this is horizontal so only the number matters (A20 = row 20)
    ThisWorkbook.Worksheets.HPageBreaks.Add Range("A20")

    'this is vertical so only the letter matters (D1 = column D)
    ThisWorkbook.Worksheets.VPageBreaks.Add Range("D1")

    this adds the pagebreaks to ALL the worksheets in the open workbook.
    use ThisWorkbook.Worksheets(x) to do it on 1 sheet only.

    warning though: Excel 2002 could *hang* when using the hpagebreaks.add or/and vpagebreaks.add function. this might or might not be fixed in the current service pack (don't know as i switched to office 2003 before this was fixed).

    i hope this helps !

    LVL 4

    Author Comment


    Thank you.  That worked perfectly!

    Thanks again.

    LVL 4

    Expert Comment

    cheers dude, you're welcome ! :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now