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?
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

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
16,414
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,321
Messages
5,600,948
Members
414,417
Latest member
Nobu

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