+ Reply to Thread
Results 1 to 2 of 2

Macro need to change print areas based on Populated rows

  1. #1
    Registered User
    Join Date
    05-21-2010
    Location
    vancouver, washington
    MS-Off Ver
    Microsoft Office Excel 2007
    Posts
    7

    Macro need to change print areas based on Populated rows

    I have a template that could be any where from 12 rows to 1500 rows of data, is there a macro that will look for the last populated row (however, could contain a formula but no value) and stop the print area as to not print extra blank pages?

  2. #2
    Registered User
    Join Date
    07-29-2010
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro need to change print areas based on Populated rows

    I have a fairly specific data area, but this might help you. Change the last Row and last Column from A & 1 if you don't have data on A or row 1. Choose the longest column and longest row. I have a specific row and a specific column which I always need to use for the total page length/width.

    Sub PageSetup
    Dim LastRow As Long
    Dim LastCol As Long
    Dim myRng As Range
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    Set myRng = .Range("A1", .Cells(LastRow, LastCol))
    .PageSetup.PrintArea = myRng.Address(external:=True)
    End With
    End Sub

+ 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