+ Reply to Thread
Results 1 to 2 of 2

dynamic print range

  1. #1
    Registered User
    Join Date
    01-29-2007
    Posts
    10

    dynamic print range

    I have this macro:
    ---------------------------------------------------
    Sub setprintarea()
    Dim myrange As String
    myrange = Cells(Rows.Count, 37).End(xlUp).Address
    ActiveSheet.PageSetup.PRINTAREA = "$A$1:" & myrange
    ActiveWindow.SelectedSheets.PrintOut Copies:=1

    End Sub

    ----------------------------------------------------

    how do i modify this macro to add additional column which happens to have data in only some of the cells.

    myrange = Cells(Rows.Count, 38).End(xlUp).Address

    will only set the range where the last input in that column is and will omit the rest of data in column 37 from that point on,

    Please help

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi,

    Try the following line of code (just replace "YourSheetName" with the sheet name the code is to be used for):

    ActiveSheet.PageSetup.PrintArea = "$A$1:AK" & Sheets("YourSheetName").Range("AK65536").End(xlUp).Row

    Hope this helps.

    Robert

+ 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