Consulting

Results 1 to 7 of 7

Thread: Print Visible data rows

  1. #1
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location

    Print Visible data rows

    The following code is designed to print only the visible rows. But the code sets print area to individual visible rows.

    [vba]Sub PrintDialogByChangingNumber()
    Application.ScreenUpdating = False
    Dim LR As Long
    LR = Range("D" & Rows.Count).End(xlUp).Row
    With ActiveSheet.PageSetup
    .Orientation = xlLandscape
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .PrintArea = Range("D3:P" & LR).SpecialCells(xlCellTypeVisible).Address
    End With
    Application.Dialogs(xlDialogPrint).Show
    Range("P4").Value = Range("P4").Value + 1
    Application.ScreenUpdating = True
    End Sub[/vba]
    How could the code be changed so that it selects the visible rows as a whole?

    Any help on this would be kindly appreciated.

    Thanks in advance.
    Best Regards,
    adamsm

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I don't think you need to do that.
    [VBA].PrintArea = Range("D3:P" & LR).Address[/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 Contributor
    Joined
    Apr 2010
    Posts
    182
    Location
    Thanks for the reply.

    The row where I want the print area to start is; from row 3 with columns D to P.

    So do you mean having that situation I don't need the above line?

    Any suggestion on this would be kindly appreciated.
    Best Regards,
    adamsm

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    If cells are not visible, they won't print.
    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'

  5. #5
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location
    But removing that line does not set my print area? How can I overcome that?
    Best Regards,
    adamsm

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    see Post 2
    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'

  7. #7
    VBAX Contributor
    Joined
    Apr 2010
    Posts
    182
    Location
    Thanks for letting me know that. Now I've figured that out.
    Best Regards,
    adamsm

Posting Permissions

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