+ Reply to Thread
Results 1 to 17 of 17

Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

  1. #1
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Clarification of what I need the macro


    "I want to print pages with all visible data after filtering, but each printed page should have the 4 header rows and 50 rows with data, repeating until we reach the end of data".
    Please confirm if that's actually what you're looking for...
    Thank You JasperD for pointing out that I wasn't as clear on what I needed it to do.

    I am looking for a way to set the print area on my filtered information to 50 rows plus the 4 header rows. I currently have user forms to filter the data, but when I print it out (either on paper or pdf) I get all different amounts of rows in the printed copy do to the filtered information. In uploaded sample it is Print_Form user form

    current code for my print form looks like this:
    Please Login or Register  to view this content.
    Thank You in advance for all your help

    sample3.zip
    Last edited by meabrams; 04-04-2015 at 03:26 PM. Reason: Clarify What I need the macro to do

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Add this after filtering the sheet:

    Please Login or Register  to view this content.
    that will count the visible rows and print the 4 header rows + 50 visible rows.
    Please click the * below if this helps

  3. #3
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    That seems to code seems to hide /unselected for printing everything after the 56 mark. I need to be able to print all the filtered information but I need only 50 plus the 4 rows header per page.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Did you actually try it....?

    It counts the number of visible rows, starting at row 7.


    If there is no filter applied, the printable rows with data would be 7-56 and the count would give 50 immediately.
    That's why the code doesn't loop through 7 - 55, rather starts at 56.
    Read it again (and try it) - it makes sense
    Last edited by JasperD; 04-04-2015 at 06:20 AM.

  5. #5
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    I tried the macro as a stand alone after all filtering was applied and for some reason it is still not looping so I have printable data 54 rows (50 rows of data plus headers) per page it is still un-selecting information after the 56 mark. Im not trying to say it doesn't make sense, it just doesn't seem to be looping as intended

  6. #6
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    I tried it on your sheet after I did some filter and it worked fine.

    It shouldn't "unselect" anything, since it doesnt select anything anywhere.
    The only thing it does is say "from row 7 down, count the visible row and when at 50, make that the printable area".

    Having said that, I just see your addition "per page" - so basically you want to print all data, but 50 rows per page
    So it can be multiple pages?

    In that case your request is not "I want to print 50 rows and the 4 header rows" , but your request is:

    "I want to print pages with all visible data after filtering, but each printed page should have the 4 header rows and 50 rows with data, repeating until we reach the end of data".
    Please confirm if that's actually what you're looking for...

  7. #7
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Yes that is exactly what I need it to do... and I wanted to change the title of this after I posted and it doesn't seem to have that option on this forum.

  8. #8
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    I updated the first post in hopes that it clarifies what I need the macro to do Thank you for pointing out that I was very unclear with my first post/title of the thread

  9. #9
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Perhaps something like this:

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    To try this I created a seprate button and copy and pasted your macro to see if it would do what I needed it

    I get a run-time error '1004:
    No cells were found.

    Debugging point
    Please Login or Register  to view this content.
    Thank you for continuing to help work through this.
    Last edited by meabrams; 04-04-2015 at 05:25 PM. Reason: Add info in red

  11. #11
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Try it in a module and then run when the active sheet is the one with the filtering.

    It's better if you can exchange the 'activesheet' with your actual worksheet name.

    So use 'With Sheets("sheetname with filters")

    If it still doesn't work for you, I'll look at it again tmrw.

  12. #12
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    so I added the sheet name to the macro and it still has the same run-time error. The sheet itself is filtered before I try this macro and it still error out. Not to sure whats causing this to error out.... I was wondering if x need to be expressed with Dim in the macro at all?

    Please Login or Register  to view this content.

  13. #13
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    x should have been dimmed, but that's not the cause of the error.
    It errors when the first row (7) is invisible - should've seen that yesterday, sorry.

    Change as follows:
    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Your coding seems to work, but I was wondering it may setting the print area to a default area of A3:NH245 and then using pagebreaks to get the desired effects of 54 rows per page (4 header rows plus 50 rows

  15. #15
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    If you set pagebreaks, you won't get the header rows duplicated on each page.
    That's why I went to way of setting the printarea for 4 top rows + 50 visible rows instead.

  16. #16
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    Would pagebreaks work if I already set Print Titles under the Page Setup?

  17. #17
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Macro To Set Print area to a max of 50 (plus Header rows) on filtered information

    At this point I think I could deal with it not having the header rows on every page, but I would still need the macro to count 50 per page. It should only give 2 pages for any given time unless the end user decides to print the entire unfiltered sheet.

+ 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] Deleting Filtered Rows But Not The Header
    By rbion in forum Excel General
    Replies: 4
    Last Post: 04-15-2014, 09:06 AM
  2. Macro - Set Print Area for Changing Data Area
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-27-2013, 04:19 AM
  3. Replies: 1
    Last Post: 09-05-2013, 03:32 AM
  4. [SOLVED] Assitance with macro to format, insert header and set print area
    By benji_tsl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2012, 10:49 AM
  5. Set Print Area Macro - Exclude Blank Rows
    By shudder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2009, 10:31 PM

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