03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I am sorry if this is already addressed elsewhere - I have searched and read hundreds of posts and yet to find what I need. This seems so simple yet.....
I have code written to sync the page fields on many worksheets based on the main pivot table selection. I would like to group and print all the pivot tables once a different page field is selected, no problem, except I need code to format each pivot table to pick up all the rows and adjust to the correct number of pages once the page field changes. Here is what I have pieced together, it does nothing at this point, can someone help me or point me to the answer please:
=============================================
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Select Case ActiveSheet.Name
Case "Vol by Customer"
Dim LR As Long
LR = Cells(Rows.Count, "D").End(xlUp).Row
Dim myRange As String
myRange = Range("$A$1:D" & LR).Address
With ActiveSheet
.PageSetup.PrintArea = myRange
.PrintOut
End With
Case Else: ActiveSheet.PrintOut
End Select
Application.EnableEvents = True
End Sub
================================
consider me "frustrated" ray:
I have code written to sync the page fields on many worksheets based on the main pivot table selection. I would like to group and print all the pivot tables once a different page field is selected, no problem, except I need code to format each pivot table to pick up all the rows and adjust to the correct number of pages once the page field changes. Here is what I have pieced together, it does nothing at this point, can someone help me or point me to the answer please:
=============================================
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Select Case ActiveSheet.Name
Case "Vol by Customer"
Dim LR As Long
LR = Cells(Rows.Count, "D").End(xlUp).Row
Dim myRange As String
myRange = Range("$A$1:D" & LR).Address
With ActiveSheet
.PageSetup.PrintArea = myRange
.PrintOut
End With
Case Else: ActiveSheet.PrintOut
End Select
Application.EnableEvents = True
End Sub
================================
consider me "frustrated" ray: