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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,239
Members
448,879
Latest member
VanGirl

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