+ Reply to Thread
Results 1 to 5 of 5

Code for Printing Discontiguous Ranges

  1. #1
    Registered User
    Join Date
    12-28-2003
    Posts
    30

    Code for Printing Discontiguous Ranges

    Excel version: 11 (2003 SP2)
    OS: WXP SP2

    I have a worksheet that has monthly, quarterly and year columns. The rows are various items whose sales figures are recorded in the cells. The columnar layout is the three months of a quarter followed by the quarter summary.

    For the yearly summary report, I want to print each quarter and the year totals adjacent to each other. Operating on the worksheet itself, i.e., without VBA code, this is fairly straightforward. Hide all months and print the area with the quarter and year columns.

    When I specify a print area in VBA as, for example, ThisPrintArea = "Q1, Q2, Q3, Q4, Year", where Qx and Year are non-adjacent ranges, I get five pages instead of one. Each page has the horizontal and vertical repeating rows with one range on each page.

    I know I can change the layout so that all the months are together and all the quarters plus the year are together but I'd like to know how one accomplishes the desired result in VBA.

    Thanks,

    - Al

  2. #2
    Tom Ogilvy
    Guest

    Re: Code for Printing Discontiguous Ranges

    Same as manually. Hide the monthly columns, print the whole rectangular
    area (one single range which includes all the data to print), unhide the
    monthly columns.

    --
    Regards,
    Tom Ogilvy


    "GoFigure" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Excel version: 11 (2003 SP2)
    > OS: WXP SP2
    >
    > I have a worksheet that has monthly, quarterly and year columns. The
    > rows are various items whose sales figures are recorded in the cells.
    > The columnar layout is the three months of a quarter followed by the
    > quarter summary.
    >
    > For the yearly summary report, I want to print each quarter and the
    > year totals adjacent to each other. Operating on the worksheet itself,
    > i.e., without VBA code, this is fairly straightforward. Hide all months
    > and print the area with the quarter and year columns.
    >
    > When I specify a print area in VBA as, for example, ThisPrintArea =
    > "Q1, Q2, Q3, Q4, Year", where Qx and Year are non-adjacent ranges, I
    > get five pages instead of one. Each page has the horizontal and
    > vertical repeating rows with one range on each page.
    >
    > I know I can change the layout so that all the months are together and
    > all the quarters plus the year are together but I'd like to know how
    > one accomplishes the desired result in VBA.
    >
    > Thanks,
    >
    > - Al
    >
    >
    > --
    > GoFigure
    > ------------------------------------------------------------------------
    > GoFigure's Profile:

    http://www.excelforum.com/member.php...fo&userid=4274
    > View this thread: http://www.excelforum.com/showthread...hreadid=493043
    >




  3. #3
    Registered User
    Join Date
    12-28-2003
    Posts
    30
    Perhaps I'm not coding this correctly. I have tried your sugestion, Tom, but it still results in all the columns in the range, including the hidden ones.

    Please Login or Register  to view this content.
    This results in two pages:
    • Page 1 - Q1 totals, Apr, May, June
    • Page 2 - Q2 totals

    - Al

    Quote Originally Posted by Tom Ogilvy
    Same as manually. Hide the monthly columns, print the whole rectangular
    area (one single range which includes all the data to print), unhide the
    monthly columns.

    --
    Regards,
    Tom Ogilvy


    "GoFigure" <[email protected]> wrote in
    message news:[email protected]...[color=blue]
    >
    > Excel version: 11 (2003 SP2)
    > OS: WXP SP2
    >
    > I have a worksheet that has monthly, quarterly and year columns. The
    > rows are various items whose sales figures are recorded in the cells.
    > The columnar layout is the three months of a quarter followed by the
    > quarter summary.
    >
    > For the yearly summary report, I want to print each quarter and the
    > year totals adjacent to each other. Operating on the worksheet itself,
    > i.e., without VBA code, this is fairly straightforward. Hide all months
    > and print the area with the quarter and year columns.
    >
    > When I specify a print area in VBA as, for example, ThisPrintArea =
    > "Q1, Q2, Q3, Q4, Year", where Qx and Year are non-adjacent ranges, I
    > get five pages instead of one. Each page has the horizontal and
    > vertical repeating rows with one range on each page.
    >
    > I know I can change the layout so that all the months are together and
    > all the quarters plus the year are together but I'd like to know how
    > one accomplishes the desired result in VBA.
    >
    > Thanks,
    >
    > - Al
    >
    >
    > --
    > GoFigure
    Last edited by GoFigure; 12-13-2005 at 01:10 PM.

  4. #4
    Registered User
    Join Date
    12-28-2003
    Posts
    30

    Re: Code for Printing Discontiguous Ranges

    Does anyone have a, or some, suggestions? I'd appreciate any.

    Many thanks,

    - Al

    Quote Originally Posted by GoFigure
    Perhaps I'm not coding this correctly. I have tried your sugestion, Tom, but it still results in all the columns in the range, including the hidden ones.

    Please Login or Register  to view this content.
    This results in two pages:
    • Page 1 - Q1 totals, Apr, May, June
    • Page 2 - Q2 totals

    - Al

  5. #5
    Dave Peterson
    Guest

    Re: Code for Printing Discontiguous Ranges

    Make sure you don't have any manual page breaks in that range (even in the
    hidden columns).

    And make sure your set the print to only one page wide (or one page tall??).

    GoFigure wrote:
    >
    > Does anyone have a, or some, suggestions? I'd appreciate any.
    >
    > Many thanks,
    >
    > - Al
    >
    > GoFigure Wrote:
    > > Perhaps I'm not coding this correctly. I have tried your sugestion, Tom,
    > > but it still results in all the columns in the range, including the
    > > hidden ones.
    > >
    > > >

    > Code:
    > --------------------
    > > > Sheets(sThisSheetName).Columns("B:J").Hidden = True ' Hide Jan - Mar

    > > Sheets(sThisSheetName).Columns("M:U").Hidden = True ' Hide Apr - Jun
    > > PA_PrintRange = "$K10:$W52" ' K:L = Q1 totals and V:W = Q2 totals

    > --------------------
    > > >

    > >
    > > This results in two pages:
    > > > > >

    > - Page 1 - Q1 totals, Apr, May, June
    > - Page 2 - Q2 totals
    > > > >

    > >
    > > - Al

    >
    > --
    > GoFigure
    > ------------------------------------------------------------------------
    > GoFigure's Profile: http://www.excelforum.com/member.php...fo&userid=4274
    > View this thread: http://www.excelforum.com/showthread...hreadid=493043


    --

    Dave Peterson

+ 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