Problems with Dynamic Page Setup/Page Breaks

Achelray

New Member
Joined
Sep 7, 2011
Messages
3
Hi,

Using Windows XP and Excel 2003. Trying to create dynamic code for three print scenarios (from all columns visible to a few columns hidden to the most columns hidden.) All columns visible (EXPANDED) is working, prints what I want on each legal size page; having problem with other two (SEMI COLLAPSED and COLLAPSED) Keep seeing the same page breaks for expanded. I have 12 months worth of data with 14 colums in each month and 24 "header" columns to the far left. EXPANDED shows header columns and 1 month of data on each legal page. SEMI COLLPASED shows 15 header columns and 14 columns for each month, but I want the 15 header columns and 2 months of data on each legal page. COLLAPSED shows 15 header columns and 6 columns for each month, but I want the 15 header columns and 3 months of data on each legal page. Below is the code I have for EXPANDED, SEMICOLLAPSED and COLLAPSED, what am I doing wrong?

Sub EXPANDEDPRINT()
Set wbBuyGuide = ActiveWorkbook
Set wsBUFBG = wbBuyGuide.Worksheets("BUYER UP FRONT BUY GUIDE")
Application.ScreenUpdating = False

lrBUFBG = wsBUFBG.Range("C65536").End(xlUp).Row
wsBUFBG.ResetAllPageBreaks
'wsBUFBG.PageSetup.PrintArea = "C1:GL" & lrBUFBG & ""
With wsBUFBG.PageSetup
.PrintArea = "C1:GL" & lrBUFBG & ""
.PrintTitleRows = "$1:$10"
.PrintTitleColumns = "$C:$Z"
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&Z&F"
.RightFooter = "Page &P"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 42
'.FitToPagesWide = 12
'.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
End With
With wsBUFBG

.VPageBreaks.Add Before:=.Range("AO1")
.VPageBreaks.Add Before:=.Range("BC1")
.VPageBreaks.Add Before:=.Range("BQ1")
.VPageBreaks.Add Before:=.Range("CE1")
.VPageBreaks.Add Before:=.Range("CS1")
.VPageBreaks.Add Before:=.Range("DG1")
.VPageBreaks.Add Before:=.Range("DU1")
.VPageBreaks.Add Before:=.Range("EI1")
.VPageBreaks.Add Before:=.Range("EW1")
.VPageBreaks.Add Before:=.Range("FK1")
.VPageBreaks.Add Before:=.Range("FY1")
.Range("H1").ClearContents
.Range("H1").Select
End With

End Sub


Sub SEMICOLLAPSEDPRINT()
Dim rngMyRange As Range, rngCell As Range
Set wbBuyGuide = ActiveWorkbook
Set wsBUFBG = wbBuyGuide.Worksheets("BUYER UP FRONT BUY GUIDE")
Application.ScreenUpdating = False
lrBUFBG = wsBUFBG.Range("C65536").End(xlUp).Row
With wsBUFBG
wsBUFBG.ResetAllPageBreaks

End With

'wsBUFBG.PageSetup.PrintArea = "C1:GL" & lrBUFBG & ""
With wsBUFBG.PageSetup
.PrintArea = "C1:GL" & lrBUFBG & ""
.PrintTitleRows = "$1:$10"
.PrintTitleColumns = "$C:$Z"
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&Z&F"
.RightFooter = "Page &P"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 44
'.FitToPagesWide = 3
'.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
End With

With wsBUFBG


.VPageBreaks.Add Before:=.Range("BQ1")
.VPageBreaks.Add Before:=.Range("DG1")
.VPageBreaks.Add Before:=.Range("EW1")


.Range("H1").ClearContents
.Range("H1").Select

End With

End Sub

Sub COLLAPSEDPRINT()
Dim rngMyRange As Range, rngCell As Range
Set wbBuyGuide = ActiveWorkbook
Set wsBUFBG = wbBuyGuide.Worksheets("BUYER UP FRONT BUY GUIDE")
Application.ScreenUpdating = False
lrBUFBG = wsBUFBG.Range("C65536").End(xlUp).Row
With wsBUFBG
wsBUFBG.ResetAllPageBreaks

End With

'wsBUFBG.PageSetup.PrintArea = "C1:GL" & lrBUFBG & ""
With wsBUFBG.PageSetup
.PrintArea = "C1:GL" & lrBUFBG & ""
.PrintTitleRows = "$1:$10"
.PrintTitleColumns = "$C:$Z"
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&Z&F"
.RightFooter = "Page &P"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 55
'.FitToPagesWide = 3
'.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
End With

With wsBUFBG

.VPageBreaks.Add Before:=.Range("BC1")
.VPageBreaks.Add Before:=.Range("CE1")
.VPageBreaks.Add Before:=.Range("DG1")
.VPageBreaks.Add Before:=.Range("EI1")
.VPageBreaks.Add Before:=.Range("FK1")


.Range("H1").ClearContents
.Range("H1").Select

End With

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,551
Messages
6,179,476
Members
452,915
Latest member
hannnahheileen

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