Print Macro Help - Is it possible to Macro so only the pages in a sheet that have data in certain cells are printed?

Barryoffshore

Board Regular
Joined
Feb 21, 2005
Messages
73
I have a workbook that has 87 sheets, and each sheet has 21 printable pages. Is there a macro which will print only the pages that have entries on them? For instance, if on a single sheet, there is data in cells E7, E37, E66 & E95, only the pages that have those cells in them will print. Is a macro like this possible and if so, can someone help me with it please???

Thank you!!!
Bear
 
@Barryoffshore
I think the problem is that Excel won't know what form has data in it and what form doesn't, therefore won't be able to print the required forms.
you state
For instance, if on a single sheet, there is data in cells E7, E37, E66 & E95, only the pages that have those cells in them will print.

My suggestion would be to list which cells are the "trigger" cells for ALL 21 pages, then tell us the range for each page.
Maybe then we could help !
I'd also suggest selecting each "page" and giving it a named range....and make the names concurrent like, Barry1, Barry2, etc.
That way we could loop through each "page" to see if it needed printing.

Your request is not quite as simple as it may appear to you...:biggrin:
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I didn't think it was going to be easy... I am far from being anything more than a novice at best, but I try to read and learn before I ask on here. Having someone do something for me makes it hard for me to learn... but sometimes (lots of times!!!) I don't have any choice but to ask for help.

And, I don't know how to express the gratitude and admiration I have for all of who have helped me - today and every time in the past!

Bear
 
Upvote 0
It will take me a little while to gather the "trigger" cells and ranges - working on that now... QUESTION! Can the Named Ranges be the same for each of the 87 sheets? I honestly don't know much about "Named Ranges" but I do know a little and will do my best.

THANK YOU all for being so patient. I must seem like a complete idiot compared to the level of brilliance you all have!!!



@Barryoffshore
I think the problem is that Excel won't know what form has data in it and what form doesn't, therefore won't be able to print the required forms.
you state


My suggestion would be to list which cells are the "trigger" cells for ALL 21 pages, then tell us the range for each page.
Maybe then we could help !
I'd also suggest selecting each "page" and giving it a named range....and make the names concurrent like, Barry1, Barry2, etc.
That way we could loop through each "page" to see if it needed printing.

Your request is not quite as simple as it may appear to you...:biggrin:
 
Last edited:
Upvote 0
Hmm, forgot about the 87 sheets...:oops:....No, the named ranges have to be different !
I'm guessing the trigger cells will be the same on each sheet ??
If so, maybe a list of the trigger cells and the range to be printed relative to each trigger.
Are the forms on each worksheet, the same for ALL 87 sheets, just with different data ??
 
Upvote 0
Yes, every sheet is exactly the same, just different sheet (tab) names. I named them all and have the "trigger" cells - let me get the ranges for each page to be printed and I'll get back with you.
 
Upvote 0
Here are the trigger cells and range for each page - and I really hope I did this right:

<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG/> </o:OfficeDocumentSettings> </xml><![endif]--> TRIGGER CELL E 7 RANGE $A1:$AC30
TRIGGER CELL E 37 RANGE $A34:$AC60
TRIGGER CELL E 66 RANGE $A63:$AC89
TRIGGER CELL E 95 RANGE $A92:$AC118
TRIGGER CELL E 124 RANGE $A121:$AC147
TRIGGER CELL E 153 RANGE $A150:$AC176
TRIGGER CELL E 183 RANGE $A180:$AC206
TRIGGER CELL E 212 RANGE $A209:$AC235
TRIGGER CELL E 241 RANGE $A238:$AC264
TRIGGER CELL E 270 RANGE $A267:$AC293
TRIGGER CELL E 299 RANGE $A296:$AC322
TRIGGER CELL E 329 RANGE $A326:$AC352
TRIGGER CELL E 358 RANGE $A355:$AC381
TRIGGER CELL E 387 RANGE $A384:$AC410
TRIGGER CELL E 416 RANGE $A413:$AC439
TRIGGER CELL E 445 RANGE $A442:$AC468
TRIGGER CELL E 475 RANGE $A472:$AC498
TRIGGER CELL E 504 RANGE $A501:$AC527
TRIGGER CELL E 533 RANGE $A530:$AC556
TRIGGER CELL E 562 RANGE $A559:$AC585
TRIGGER CELL E 591 RANGE $A588:$AC614
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:EnableOpenTypeKerning/> <w:DontFlipMirrorIndents/> <w:OverrideTableStyleHps/> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/> <w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/> <w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/> <w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/> <w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/> <w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/> <w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/> <w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/> <w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/> <w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/> <w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/> <w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/> <w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/> <w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/> <w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/> <w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/> <w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/> <w:LsdException Locked="false" Priority="37" Name="Bibliography"/> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} </style> <![endif]-->

I can't thank you enough for helping me!!!

Bear
 
Last edited:
Upvote 0
Hey Bear
This assumes that the trigger cell is not blank, to force the PrintOut
I notice some line are 29 rows apart and some are 30 !
Is that correct ?? or is there an error?
Also, if it's correct is it possible to make each "gap" the same ?, ie ALL 29 or ALL 30.
Otherwise, try this....but I'd suggest
1. try it on a test workbook
2. Use F8 to step through manually, rather than just hitting run. That way you won't print heaps of paper for nothing !!!

Code:
Sub MM1()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
    ws.Activate
    If Range("E7").Value <> "" Then Range("A1:AC30").PrintOut
    If Range("E37").Value <> "" Then Range("A34:AC60").PrintOut
    If Range("E66").Value <> "" Then Range("A63:AC89").PrintOut
    If Range("E95").Value <> "" Then Range("A92:AC118").PrintOut
    If Range("E124").Value <> "" Then Range("A121:AC147").PrintOut
    If Range("E153").Value <> "" Then Range("A150:AC176").PrintOut
    If Range("E183").Value <> "" Then Range("A180:AC206").PrintOut
    If Range("E212").Value <> "" Then Range("A209:AC235").PrintOut
    If Range("E241").Value <> "" Then Range("A238:AC264").PrintOut
    If Range("E270").Value <> "" Then Range("A267:AC293").PrintOut
    If Range("E299").Value <> "" Then Range("A296:AC322").PrintOut
    If Range("E329").Value <> "" Then Range("A326:AC352").PrintOut
    If Range("E358").Value <> "" Then Range("A355:AC381").PrintOut
    If Range("E387").Value <> "" Then Range("A384:AC410").PrintOut
    If Range("E416").Value <> "" Then Range("A413:AC439").PrintOut
    If Range("E445").Value <> "" Then Range("A442:AC468").PrintOut
    If Range("E475").Value <> "" Then Range("A472:AC498").PrintOut
    If Range("E504").Value <> "" Then Range("A501:AC527").PrintOut
    If Range("E533").Value <> "" Then Range("A530:AC556").PrintOut
    If Range("E562").Value <> "" Then Range("A559:AC585").PrintOut
    If Range("E591").Value <> "" Then Range("A588:AC614").PrintOut
Next ws
Application.ScreenUpdating = True
End Sub
 
Upvote 0
This works and only prints the pages in which the trigger cells are true, however it prints out for all 87 sheets. I cleared all the trigger cells for all but 1 sheet and ran the macro - and it only printed the one sheet, but it printed 87 copies of that one sheet.

You were right - this is a tough one!

Thank you for all your help!!!
 
Upvote 0
Hey Michael M. - I figured out how to fix it!!! Look at the code below and you'll see the little change I made to the code you wrote - now it prints the pages with data, but only in the sheet I'm in... THANK YOU SO VERY MUCH FOR ALL YOUR HELP!!!

Code:
Sub BLM_PRINTSHEETS_THISWORKBOOK()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWindow.SelectedSheets
    ws.Activate
    If Range("E7").Value <> "" Then Range("A1:AC30").PrintOut
    If Range("E37").Value <> "" Then Range("A34:AC60").PrintOut
    If Range("E66").Value <> "" Then Range("A63:AC89").PrintOut
    If Range("E95").Value <> "" Then Range("A92:AC118").PrintOut
    If Range("E124").Value <> "" Then Range("A121:AC147").PrintOut
    If Range("E153").Value <> "" Then Range("A150:AC176").PrintOut
    If Range("E183").Value <> "" Then Range("A180:AC206").PrintOut
    If Range("E212").Value <> "" Then Range("A209:AC235").PrintOut
    If Range("E241").Value <> "" Then Range("A238:AC264").PrintOut
    If Range("E270").Value <> "" Then Range("A267:AC293").PrintOut
    If Range("E299").Value <> "" Then Range("A296:AC322").PrintOut
    If Range("E329").Value <> "" Then Range("A326:AC352").PrintOut
    If Range("E358").Value <> "" Then Range("A355:AC381").PrintOut
    If Range("E387").Value <> "" Then Range("A384:AC410").PrintOut
    If Range("E416").Value <> "" Then Range("A413:AC439").PrintOut
    If Range("E445").Value <> "" Then Range("A442:AC468").PrintOut
    If Range("E475").Value <> "" Then Range("A472:AC498").PrintOut
    If Range("E504").Value <> "" Then Range("A501:AC527").PrintOut
    If Range("E533").Value <> "" Then Range("A530:AC556").PrintOut
    If Range("E562").Value <> "" Then Range("A559:AC585").PrintOut
    If Range("E591").Value <> "" Then Range("A588:AC614").PrintOut
        Next ws
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi,

I see you have a answer. But thought I'd show you my code.
My code is a little longer.
Code:
Sub Page_Print()
Dim p As Long
Dim ws As Worksheet
p = 1
For Each ws In ActiveWindow.SelectedSheets
    ws.Activate
    For x = 1 To Application.ExecuteExcel4Macro("Get.Document(50)")
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E7").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E37").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E66").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E95").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E124").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E153").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E183").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E212").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E241").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E270").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E299").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E329").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E358").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E387").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E416").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E445").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E475").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E504").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E533").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E562").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    ElseIf Range("E591").Value <> "" Then
        ActiveSheet.PrintOut From:=x, To:=x
    End If
    p = p + 1
    Next x
Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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