Exclude hidden rows when printing

PuntingJawa

Board Regular
Joined
Feb 25, 2021
Messages
158
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a workbook that consolidates serial numbers for identification tags that get placed on crates.
Excel Formula:
Sub MyHideRows()

    Dim r As Long

    Application.ScreenUpdating = False

'   Check rows 2:681
    For r = 2 To 681
        Rows(r).EntireRow.Hidden = (Cells(r, "B") = "")
    Next r
    
    
    Application.ScreenUpdating = True

End Sub

I use this in a button to hide rows in the range of 2-681 based on weather or not information is in column B (Helper cell that places a 1 if there is greater than 1 in column G which is the QTY of that item).
I have set page breaks every 40 rows which separates based on crate.

My question is, is there a way to automatically exclude any of the hidden rows when printing? I know I can do it manually by highlighting what I want to print, but I am trying to keep this simplistic for less savvy users in case I take a day off.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
When I use filters or hide a row manually I have no problem with printing. It normally doesn't show hidden rows.
 
Upvote 0
When I use filters or hide a row manually I have no problem with printing. It normally doesn't show hidden rows.
Tried the filter thing. My guys aren't at all computer savvy, which is why I linked it to a button.

There's just too many lines to do it manually.
 
Upvote 0
So, it shouldn't matter if you hide the rows or filter the table using VBA, hidden rows should not show when printing.
 
Upvote 0
Yes, I meant blank. Was typing on mobile. I have just arrived to work and reset the page breaks. Still showing blank pages in the print preview.
Where exactly do these "blank" pages that print show up?
At the very end of your data, or interspersed between pages of data?

Check your print range.
Do you have it set to include extra rows after the end of your data?
Or does it include extra columns out past your last column of data?
 
Upvote 0
Where exactly do these "blank" pages that print show up?
At the very end of your data, or interspersed between pages of data?

Check your print range.
Do you have it set to include extra rows after the end of your data?
Or does it include extra columns out past your last column of data?
I'll try and break down how the whole workbook page breaks are set.
Information is in Columns C to G. Print area is C2:G681.
Helper Column is B which places a 1 if there is information in Column C (Used for the VBA in my first post to auto hide rows).
Each sheet consists of 40 rows starting at #2 with page breaks between for a total of 17 pages to print.

With that being said, I'll answer you quests in sequence as best as I can.
Where exactly do these "blank" pages that print show up?
The blank pages show in-between. If there is no data and I apply the hide rows VBA, it should not show
At the very end of your data, or interspersed between pages of data?
It seems to be printing all of the print area set.
Do you have it set to include extra rows after the end of your data?
No, I only have the range where data would be.
Or does it include extra columns out past your last column of data?
No, I have no extra beyond what I am printing.
 
Upvote 0
How many pages does it end up printing, exactly?
Is there any kind of "pattern", i.e. sheet of data, followed by blank sheet, followed by sheet of data, followed by blank sheet, etc.?
Is column G always populated with data, or are there a lot of blanks in column G?

What happens if you temporarily remove ALL page breaks and try printing?
 
Upvote 0

Forum statistics

Threads
1,223,877
Messages
6,175,138
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top