Pivot table only updates via VBA when sheet is active

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
Code:
With Sheet6
        
        .PivotTables("PivotTable2"). _
            PivotFields("Name").CurrentPage = "Text"
 
End With

This code is not working. If I change "Sheet6" to "ActiveSheet" and activate Sheet6, it works just fine.

I don't want to have to activate all the sheets that I'm going to be working with. Is there any way to fix this code?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
bump

Edit: You know, come to think of it, when I "PrintOut" the pivot reports I think that the sheets are being activated anyway, so maybe it doesn't really matter if I activate the sheets first and just do it that way.

If anybody has any input to offer on this that'd be great, but otherwise I guess I know what I'm gonna do.
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
17,035
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi Glory,

Your code worked perfectly for me - i havent faced any problem with something like this

Sheet1.Activate
With Sheet4

.PivotTables("PivotTable1"). _
PivotFields("Code").CurrentPage = "1"

End With

So, i dont know how to help you...

M.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,682
Messages
5,838,784
Members
430,568
Latest member
bortey

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
Top