Select Entire PivotTable, Refresh, Resize Another Doesn't work!

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:
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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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