Print Preview

Billdub417

New Member
Joined
Nov 5, 2019
Messages
32
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
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Watch MrExcel Video

Forum statistics

Threads
1,126,971
Messages
5,621,891
Members
415,864
Latest member
cybid

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
Top