Print Preview

Billdub417

New Member
Joined
Nov 5, 2019
Messages
45
Hello,

I'm trying to add a macro on a sheet to print preview the page, after hiding blank lines.

Id like the end result to be a print preview on 2 pages - 1st to cover A1:C449 and the second to show A450:C620

The below code works but it shows my data over 4 pages rather than 2 - is it possible to restrict it to 2 and scale to fit?

Glad of some help.

Thanks

VBA Code:
Sub Hideandprint()

Dim cell As Range
    For Each cell In Range("b6:b620")
        If Not IsEmpty(cell) Then
            If cell.value = 0 Then
                cell.EntireRow.Hidden = True
            End If
        End If
    Next
With Sheets("sheet1")
    ActiveSheet.PageSetup.PrintArea = "a1:c449,a450:C620"
    Sheets("sheet1").PrintPreview
    End With

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,212,933
Messages
6,110,756
Members
448,295
Latest member
Uzair Tahir Khan

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