Need help to prevent printing of blank pages

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
781
Office Version
  1. 365
Platform
  1. Windows
Hi,
i have this formula:
Code:
Sub Macro5d() Sheets("Report").Select
Range("I21").Select
    ActiveCell.FormulaR1C1 = "Time Taken"
     Selection.Font.Bold = True
     Range("I22").Select
    ActiveCell.FormulaR1C1 = "(hh:mm:ss)"
    Range("I23").Select
    ActiveCell.FormulaR1C1 = "=IF(RC[-7]="""","""",RC[-7]-R[-1]C[-7])"
    Range("I23").Select
    Selection.AutoFill Destination:=Range("I23:I4000"), Type:=xlFillDefault
    Range("I23:I4000").Select
    Selection.NumberFormat = "h:mm:ss"
                 Rows("21:21").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$21:$M$4000").AutoFilter Field:=9, Criteria1:="<>"
Sheets("Report").PrintOut Copies:=1
     Sheets("Main").Select
   
End Sub

very bad coding i know lol but it works to an extent

i used this to get it from printing 87 blank pages to just 1
Code:
ActiveSheet.Range("$A$21:$M$4000").AutoFilter Field:=9, Criteria1:="<>"

it seems to always print the pages with data + 1 blank page and not sure why
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Here's a workaround:
Rich (BB code):
Sheets("Report").PrintOut to:=Sheets("Report").PageSetup.Pages.Count - 1

 
Upvote 0

Forum statistics

Threads
1,203,060
Messages
6,053,305
Members
444,651
Latest member
markkuznetsov1

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