+ Reply to Thread
Results 1 to 3 of 3

Setting Variable Print Area

Hybrid View

  1. #1
    Registered User
    Join Date
    07-15-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    77

    Setting Variable Print Area

    Hi

    I need a macro that will set a variable print area based on whether there is a value in Column A. The whole range to select to print would be columns A to N. I have tried adapting code from this forum but to no avail.

    Can anyone help?

    Thanks
    Mark
    Last edited by markrennolds; 05-04-2010 at 01:55 PM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Setting Variable Print Area

    So if there is a value in A10 you want the print area to be set as A1:N10 no matter what other rows are populated in the other columns?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Setting Variable Print Area

    Something like this:
    Option Explicit
    
    Sub SetPrintArea()
    Dim LR As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
        
        ActiveSheet.PageSetup.PrintArea = "$A$1:$N$" & LR
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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