print areas in vba

markh1182

New Member
Joined
Apr 25, 2006
Messages
48
Hi,

I have this code that sets the print area. Is there a way to amend slightly so it says that each page should have 59 rows from the excel spreadsheet? This is because it is putting page breaks in weird places, and not just sticking to the page setup format, from the looks of it.

Ta,
Mark

Code:
Sub PrintArea()

bottom = ActiveSheet.Range("N65536").End(xlUp).Row

    Cells.Select
    ActiveSheet.PageSetup.PrintArea = ""
    
    Range("A1").Select
    
MyRange = ("I1" & ":" & "O" & bottom)

ActiveSheet.PageSetup.PrintArea = MyRange


End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi, Mark,

struggling for years with this from time to time, always feeling to need workarounds
why you cannot simply remove all those stupid automatic pagebreaks and put some yourself, is a mistery for me :confused:

this seems to work
Code:
Sub test()
Dim pb As HPageBreak
Dim i As Long

    For i = 1 To ActiveSheet.HPageBreaks.Count
    ActiveSheet.HPageBreaks(i).Location = Cells(i * 59, 1)
    Next i

End Sub
kind regards,
Erik
 
Upvote 0

Forum statistics

Threads
1,217,314
Messages
6,135,805
Members
449,965
Latest member
Ckl43

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