+ Reply to Thread
Results 1 to 3 of 3

Printing variable number of rows

  1. #1
    Registered User
    Join Date
    04-20-2004
    Posts
    4

    Printing variable number of rows

    How do I write a macro to print a variable number of rows from a spreadsheet?
    eg the data in todays sheet may be only 30 rows, tomorrow it may be 300 rows - or any number in between.

    Currently I have it set to print the maximum number (using Print Area) irrespective of whether they have any data in them or not & its simply a waste of time,paper & ink.

    thanks
    john

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Quote Originally Posted by JRM
    How do I write a macro to print a variable number of rows from a spreadsheet?
    eg the data in todays sheet may be only 30 rows, tomorrow it may be 300 rows - or any number in between.

    Currently I have it set to print the maximum number (using Print Area) irrespective of whether they have any data in them or not & its simply a waste of time,paper & ink.

    thanks
    john

    Hello John,

    You almost have your problem solved. You can access Excel worksheet functions through VBA. One function COUNTA can be used to find the number of none empty Rows or Columns on a worksheet. Use this to select the Range and then set Print Area to this Range.


    Hope this helps,
    Leith Ross

  3. #3
    Registered User
    Join Date
    04-20-2004
    Posts
    4

    Question

    Hi Leith

    I can see what you're getting at and now understand COUNTA but please can you help me with the syntax of incorporating this into SET PRINTAREA.

    eg I want to print out A1:D60 today and A1 to D100 tomorrow depending on the amount of data.

    thanks

    John
    ps I'm a relative novice at macros !

+ 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