+ Reply to Thread
Results 1 to 2 of 2

Setting Print Area within Excel Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    Microsoft Campus
    MS-Off Ver
    Excel 2010
    Posts
    1

    Wink Setting Print Area within Excel Macro

    Have a worksheet that creates an output based on a form input from a separate worksheet within the WB. Based on the input, it is possible to have up to 99 rows of data, but usually much less. Would like to set up a macro that only those rows in Column A that have a value are printed. Each row has an IF/THEN formula based on the form input.

    Having a hard time creating a sub-macro that will set up the print area based on the blank cells.

    Please help!

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960

    Re: Setting Print Area within Excel Macro

    Option Explicit
    
    Sub Macro1()
        Dim LastData As Long
        
        LastData = WorksheetFunction.CountIf(Range("A:A"), ">""")
    
        ActiveSheet.PageSetup.PrintArea = "$A$1:$A" & LastData
        Range("A1").Select
    End Sub
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro for setting Print Area
    By jpoppet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 05:31 AM
  2. Setting print area in a macro
    By pkenard in forum Excel General
    Replies: 4
    Last Post: 03-02-2012, 06:32 PM
  3. Macro for setting Print Area
    By Pat Parker in forum Excel General
    Replies: 0
    Last Post: 02-07-2012, 11:25 AM
  4. [SOLVED] Setting print area within macro
    By TimMalone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2005, 10:35 AM
  5. [SOLVED] Setting the Print Area in a macro.
    By Dick Snow in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2005, 11:05 AM

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