+ Reply to Thread
Results 1 to 21 of 21

print non-empty cells

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    print non-empty cells

    Hello to all
    in the attached workbook there are many empty columns.
    Is it possible to print only non-empty columns?
    Now from example attached should print columns only A:U and AP:AQ
    Of course it is not always as in the example but the non-empty columns can be more or less
    thanks you
    max
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Put into standard module:

    Please Login or Register  to view this content.
    and into ThisWorkbook code:

    Please Login or Register  to view this content.
    should works.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Hi
    It is not always as in the example but the non-empty columns can be more or less
    the macro should do everything automatically
    print button> hide empty columns

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Change this:
    Please Login or Register  to view this content.
    into this:
    Please Login or Register  to view this content.
    and should works. Hide column before print and unhide after. Automatically.
    Attached Files Attached Files

  5. #5
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Hi kokosek
    your macro works if there are no formulas in the cells
    Unfortunately where I insert your macros in all cells there are formulas
    Only in the visible cells there is a result in the others there is no result
    Now with your macros no columns are hidden

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    You send example with empty column and these columns are hidden.
    Send more proper attachment. We can't suspect that some of these column can be filled by formulas as there is any formula there.
    Last edited by KOKOSEK; 10-12-2021 at 09:39 AM.

  7. #7
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    here is example
    In the "tagli" sheet there is a button linked to the macro
    Attached Files Attached Files

  8. #8
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Try:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by KOKOSEK; 10-12-2021 at 10:15 AM.

  9. #9
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Hi kokosek
    the new macro work well.
    How to change why not print the column BB?
    Attached Files Attached Files
    Last edited by max_max; 10-12-2021 at 03:54 PM.

  10. #10
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Quote Originally Posted by max_max View Post
    How to change why not print the column BB?
    Sorry I do not understand. Do you want to hide BB or not?

    BTW: I've left unnecessary data in row 1, which have to be delete in last attachment. And change code here:

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Hi kokosek
    I have adjusted the page breaks
    Now pages 4/5/6 are blank, you can not print them?
    Of course if there were values you have to print them.
    Attached Files Attached Files

  12. #12
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Pages 4/5/6 won't be printed when there is nothing to print on them.
    That's how it looks like 'prepare for printing' (after hideColumns)
    Attached Images Attached Images
    Attached Files Attached Files

  13. #13
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Print 4/5/9 blank pages

  14. #14
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    Check attached file.
    Attached Files Attached Files

  15. #15
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Print 4/5/6 blank pages

  16. #16
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    That's probably something with your excel/printer setting as there are not.
    Attached Files Attached Files

  17. #17
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Ok kokosek
    thanks for everything
    max

  18. #18
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Hello again
    in the attached workbook the printing is now regulated in horizontal priority
    Is it possible that I print the sheet 1/3/5 together with column BB as per attached photo
    without adjusting the page breaks every time?
    Attached Images Attached Images
    Attached Files Attached Files

  19. #19
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    Maybe I explained myself wrong?
    It should work like this:

    now the page breaks are

    page 1 = D3: AA3
    page 2 = AA3: BB3

    page 3 = D42: AA42
    page 4 = AA42: BB42

    page 5 = D82: AA82
    page 6 = AA82: BB82

    if the non-empty cells are within the range D3:AA3 / D42:AA42 / D82:AA82 add column BB to the printout

    if non-blank cells are larger than normal print

    max

  20. #20
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: print non-empty cells

    I do not really know what kind of problems you are struggling with...
    Before - all columns, then empty columns hidden + still printable BB column.
    Attached Images Attached Images
    Attached Files Attached Files

  21. #21
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: print non-empty cells

    In the attached workbook there are 6 pages to print.
    The page order is in horizontal priority.
    Not all cells are non-empty.
    I ask if it is possible to add a column to the printout in this manner

    Now the page breaks are

    page 1 = C3: AC3
    page 2 = AD3: BB3

    page 3 = C43: AD43
    page 4 = AC43: BB43

    page 5 = C82: AC82
    page 6 = AD82: BB82

    if the non-empty cells are within the range C3: AC3 / C43: AD43 / C82: AC82 add column BB to the printout (esempio1)

    if the non-empty cells are higher than the range C3: AC3 / C43: AD43 / C82: AC82 and therefore are also
    in the range AD3: BB3 / AC43: BB43 / AD82: BB82 normal printing (esempio2)

    see example1 / example2 in the attached example
    Attached Files Attached Files
    Last edited by max_max; 10-15-2021 at 08:22 AM.

+ 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] Dynamic print area with empty cells
    By kinakin in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-02-2019, 11:32 AM
  2. macro print non-empty cells
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-08-2018, 04:38 PM
  3. PRINT ISSUE: Empty Print Preview
    By wedzmer in forum Excel General
    Replies: 1
    Last Post: 06-21-2018, 10:42 AM
  4. [SOLVED] Not print "empty" cells-columns
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2014, 02:25 PM
  5. Do not print if cells are empty
    By kmlloyd in forum Excel General
    Replies: 9
    Last Post: 04-22-2013, 11:50 AM
  6. [SOLVED] print only data and no empty cells
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2012, 11:22 AM
  7. Resolved >>> Checking Cells are empty before print macro
    By geff in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-25-2007, 06:33 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