+ Reply to Thread
Results 1 to 6 of 6

Set print area that is variable

  1. #1
    Registered User
    Join Date
    03-30-2010
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Set print area that is variable

    Hi All

    I have a spreadsheet, the number of columns of which are fixed, but the number of rows vary depending on data inputted.

    In cell R5, the number of the last row containing relevant data, is calculated and displayed (say "x")

    All I want to do, using VBA, is to set the print area to A1:P(X). I know this must be simple - but not for me!!

    Thanks for any help.

    Phil

  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: Set print area that is variable

    Something like this:

    Please Login or Register  to view this content.

    or

    Please Login or Register  to view this content.

    Dom
    Last edited by Domski; 03-30-2010 at 07:37 AM.
    "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 teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Set print area that is variable

    No need for VBA. Just change the definition of the Default name PrintArea.

    Click Insert - Name - Define

    If PrintArea already exists, click it. If not, create the name. Replace existing definition with / Use the formula

    =$A$1:index($P:$P,match("ZZZ",$R:$R,1))

    This range will now shrink and grow according to the last text cell in column R.

  4. #4
    Registered User
    Join Date
    03-30-2010
    Location
    Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Smile Re: Set print area that is variable

    Thanks guys. Solved it using the first suggestion, so didn't go any further, but will bear in mind the other offerings for future use.

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Set print area that is variable

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Set print area that is variable

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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