How can I locate Pivot tables in a workbook

AndyDevine1

Board Regular
Joined
Jun 1, 2006
Messages
172
hi there

There is code to update pivot tables in a workbook I've inherited

Running this is causing an error as the tables cannot locate the source data

I've gone through the many pivot tables and re-pointed them to the correct data source

When I re-run the code it is still telling me there are some pivot tables where the data source cannot be found.

I've no hidden worksheets

Is there a way I can locate the remaining pivot tables in order to fix the problem?

Many thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
So what's the problem?
 
Upvote 0
I was very pleased to see I had a response. Shame because other people may think that the one reply I've had means its been resolved when it hasnt...

Have I been unclear or have you not read my post properly?!?
 
Upvote 0
I've been through every sheet and changed the data source for all of the pivot tables I can locate

When I re-run the code it doesnt work as there are still some pivot tables I need to change it would appear

Is there a way I run a code that tells me where all of the pivot tables are in order for me to fix the problem?
 
Upvote 0
Your post seems to have changed since I posted my reply.
 
Upvote 0
Hi Rory
Can you help me...?

You're not being very helpful at the moment to be honest...with your comments

I've inherited a workbook with a refresh pivot table code in it (code is written based on the 'for each worksheet in workbook' method...

When I ran it it doesnt work as it cant find the data source for some of the pivot tables

But I cant seem to locate all of the pivot tables in the workbook (I've changed the ones I can locate)

What can i do?
 
Upvote 0
Its not me being sarcastic, its me being annoyed/frustrated as I didn't experience you wanting to help.

But thank you very much for the tip, I will look into this....
 
Upvote 0
Try this:

Code:
Sub PivotID()
    Dim wb As Workbook
    Dim sh As Worksheet
    Dim pt As PivotTable
    
    Set wb = ActiveWorkbook
    
    For Each sh In wb.Worksheets
        MsgBox sh.Name & " has " & sh.PivotTables.Count & " pivot tables"
        If sh.PivotTables.Count > 0 Then
            For Each pt In sh.PivotTables
                MsgBox pt.Name & " source data is " & pt.SourceData
            Next
        End If
    
    
     Next

End Sub
 
Upvote 0
Try this:

Code:
Sub PivotID()
    Dim wb As Workbook
    Dim sh As Worksheet
    Dim pt As PivotTable
   
    Set wb = ActiveWorkbook
   
    For Each sh In wb.Worksheets
        MsgBox sh.Name & " has " & sh.PivotTables.Count & " pivot tables"
        If sh.PivotTables.Count > 0 Then
            For Each pt In sh.PivotTables
                MsgBox pt.Name & " source data is " & pt.SourceData
            Next
        End If
   
   
     Next

End Sub
Thank you - this helped me locate a generically-named pivot table within 3 tabs of dozens of pivots!
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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