+ Reply to Thread
Results 1 to 4 of 4

Dynamic print area

Hybrid View

Guest Dynamic print area 11-09-2005, 04:30 PM
Guest Re: Dynamic print area 11-09-2005, 05:15 PM
Casey Harley, Try something like... 11-09-2005, 05:24 PM
Guest Re: Dynamic print area 11-10-2005, 09:20 AM
  1. #1
    Harley
    Guest

    Dynamic print area

    I am having trouble creating a dynamic print area. I need to print a sheet
    that is updated from other sheets in the same workbook. There will always be
    data in columns A-G and a variable number of rows.

    LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
    ActiveSheet.Range("A1:G" & LngLastRow).Select
    ActiveSheet.PageSetup.PrintArea = ("A1:G" & LngLastRow)

    I use the above code to establish the range of cells used and to then
    establish the print area. It appears to work because dashed lines are around
    the selected range, but it does not print as I had hoped. I was expecting, in
    this case, to have 2 printed sheets , but I have 4 printed sheets with
    columns F & G on pages 3 and 4.

    TIA

  2. #2
    Ron de Bruin
    Guest

    Re: Dynamic print area

    Hi Harley

    You can change the margins in pagesetup and maybe

    .PageSetup.FitToPagesWide = 1



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


    "Harley" <anonymous@nowhere.com> wrote in message news:D611A621-5BC0-45DF-B721-F615DC49BEF4@microsoft.com...
    >I am having trouble creating a dynamic print area. I need to print a sheet
    > that is updated from other sheets in the same workbook. There will always be
    > data in columns A-G and a variable number of rows.
    >
    > LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
    > ActiveSheet.Range("A1:G" & LngLastRow).Select
    > ActiveSheet.PageSetup.PrintArea = ("A1:G" & LngLastRow)
    >
    > I use the above code to establish the range of cells used and to then
    > establish the print area. It appears to work because dashed lines are around
    > the selected range, but it does not print as I had hoped. I was expecting, in
    > this case, to have 2 printed sheets , but I have 4 printed sheets with
    > columns F & G on pages 3 and 4.
    >
    > TIA




  3. #3
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245
    Harley,
    Try something like this. I'm not one of the experts, but this worked for me. Adapt as necessary.

    Option Explicit
    Private Sub PrintArea()
    Dim LngLastRow As Long

    LngLastRow = ActiveSheet.Range("G65536").End(xlUp).Row
    ActiveSheet.Range("A1:G" & LngLastRow).Select

    With ActiveSheet.PageSetup
    .PrintArea = ("A1:G" & LngLastRow)
    .FitToPagesWide = 1
    .FitToPagesTall = False

    End With
    End Sub

    HTH
    Casey

  4. #4
    Harley
    Guest

    Re: Dynamic print area

    Thank you Ron and Casey. The code now works as I had hoped.

+ 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