03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have the following macros on the Sheet code of one pivot table which works great for refreshing, selecting entire pt to print and also resizes if anything changes on the pt. I am including both sets of code below
Here is my issue, when I copy this data to another sheet and modify the sheet name and the Range("G10").Select to Range("D15").Select - this is the first cell below the values heading and to the right of the row labels - and I select that sheet which should launch the new data, it errrors out and when I choose Debug it has launched the code on the original sheet and the error is on the row of code that includes the old Range("G10").Select.
On the new code the only code I changed was the PT name and the Range Select location. Could this have something to do with the CurrentRegion.Address and is there a way to clear it? Grasping at straws here. Your help is really appreciated.
CODE ON ORIGINAL SHEET:
CODE ON SECOND SHEET:
Here is my issue, when I copy this data to another sheet and modify the sheet name and the Range("G10").Select to Range("D15").Select - this is the first cell below the values heading and to the right of the row labels - and I select that sheet which should launch the new data, it errrors out and when I choose Debug it has launched the code on the original sheet and the error is on the row of code that includes the old Range("G10").Select.
On the new code the only code I changed was the PT name and the Range Select location. Could this have something to do with the CurrentRegion.Address and is there a way to clear it? Grasping at straws here. Your help is really appreciated.
CODE ON ORIGINAL SHEET:
Code:
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
ActiveSheet.PivotTables("ShipReloadDailyPT").PivotCache.Refresh
Range("G10").Select
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
Range("C6").Select
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Range("G10").Select
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
Range("C6").Select
End Sub
CODE ON SECOND SHEET:
Code:
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
ActiveSheet.PivotTables("ShipReload1PT").PivotCache.Refresh
Range("D15").Select
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
Range("C8").Select
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Range("D15").Select
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
Range("C8").Select
End Sub