Pivot Table Select Date

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
I have a workbook with multiple tabs. One of the tabs is designated for pivot tables, in which there are multiple. I need the code to refresh all the pivot tables.

Secondly, under one of the 4 report filters on one of the pivots, I need to check the most recent date. This particular filter is entitled "RAW PROD ND DATE" and the drop down gives a bunch of dates. So the only one i need to filter is the most recent date formatted mm/dd/yy.

How do I do this?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
take a look at this

Code:
Sub RefreshAllPivots()

Dim pt As PivotTable

    For Each pt In ActiveSheet.PivotTables

        pt.RefreshTable

    Next pt   

End Sub
 
Upvote 0
For whatever reason it highlights the "pt.RefreshTable" line red for me.

Do you have any idea how to help me on the second part of my question?
 
Upvote 0
I would suggest that the activesheet be changed to the real sheet name

For Each pt In ActiveSheet.PivotTables


Sheets("yourtabnamehere").PivotTables
 
Upvote 0
Thanks for the help thus far, but it's still getting an error on that same line
Code:
Sub AllWorksheetPivots()
    Dim pt As PivotTable
    For Each pt In Sheets("BUYER PIVOT").PivotTables
        [COLOR=red]pt.RefreshTable
[/COLOR]    Next pt
End Sub
 
Upvote 0
if you hover you mouse over the "pt" what does that show? Does that result make sense to you? Is it a valid pivot table on the sheet?
 
Upvote 0
I'm sorry, I'm new at this. I hovered my mouse over that area and nothing comes up so I'm not sure what you mean entirely. Secondly, what makes a pivot table unvalid? There are multiple pivots on this worksheet and they are all standard so I'm not sure what you mean by that either.
 
Upvote 0
when you get an error on the code, click debug, that opens up the code and now in the code hover you mouse over the "pt"
pt.RefreshTable
 
Upvote 0
You know what, I tried to refresh the pivot tables manually, and it's saying "The PivotTable Fieldname is not valid. blah blah blah". I think you're right about that.
 
Upvote 0
ok glad you figured it out - so once you get any errors corrected, hopefully the code will work right.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,879
Members
452,948
Latest member
Dupuhini

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