ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vertical PageBreak not Working (https://www.excelbanter.com/excel-programming/380925-re-vertical-pagebreak-not-working.html)

Jim Rech

Vertical PageBreak not Working
 
I'm not sure what you're trying to do. If it is to have all columns in the
print range print across on one sheet, you should remove all manual page
breaks and run this:

With ActiveSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = False
End With


--
Jim
"Sprinks" wrote in message
...
| As part of a file save macro, I'm setting the print range and pagebreaks
with
| the following code. If the range is too wide to fit on the page, however,
| one or more columns may spill onto the next page. Can anyone tell me how
to
| programmatically resize the sheet to just fit within the vertical page
break?
|
| Thank you.
| Sprinks
|
| Dim wrksht As Worksheet
| Dim intLastRow as Integer
|
| wrksht.PageSetup.PrintArea = "$A$1:$F$" & intLastRow
| Call SetPageBreaks(intLastRow, "G")
|
| Public Sub SetPageBreaks(intLastRow As Integer, strColumn As String)
|
| Dim i As Integer
| ' Remove all manual page breaks
| Cells.PageBreak = xlPageBreakNone
|
| ' Set horizontal page breaks each 60 rows
| For i = 61 To intLastRow + 1 Step 60
| ActiveSheet.Rows(i).PageBreak = xlPageBreakManual
| Next i
|
| 'Set vertical page break to the left of passed column
| ActiveSheet.Columns(strColumn).PageBreak = xlPageBreakManual
|
| End Sub
|




All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com