Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Las Vegas, Nevada, USA
    Posts
    334
    Thanks
    8
    Thanked 0 Times in 0 Posts
    The size of the pivot table I am working with changes with the data but the print area originally assigned is sometimes lost. I have a macro which deletes the unused rows and columns. I can end the macro with:
    'ActiveSheet.UsedRange.Select
    but how do I get the Used Range into the
    'ActiveSheet.PageSetup.PrintArea = "$A$1:$N$43"
    so that a variable range is assigned rather than the absolute range I recorded here?

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Arcturus,

    This should work...
    Code:
    ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address
    ActiveWindow.SelectedSheets.PrintPreview
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Las Vegas, Nevada, USA
    Posts
    334
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thats the piece that I needed. Thanks Mr. RG.

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    You can also just clear the print area (set it to "") since by default Excel will print the whole thing.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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