List all Source Data in Pivot Tables

AlexPDEBMan

New Member
Joined
Dec 22, 2010
Messages
15
Hi

Is there a way I can list all of the source data in all of the Pivot tables in a workbook?

The reason I ask is that I have some source data that I don't think is used anywhere and I just want to delete it. Experience has taught me not to be so rash and I just wanted to ensure that it is not being used by this particular spreadsheet that has about 40 different pivot tables.

I guess I could write some VBA code to loop through each worksheet, then through each pivot table and write the source data location to a text stream.

There may be an Excel function I don't know about though! Can someone help?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Using VBA as mentioned, how about:

Code:
Sub PTCount()

Dim pt As PivotTable
Dim s As Worksheet, ws As Worksheet
Dim i As Long

Set ws = ThisWorkbook.Sheets.Add(ThisWorkbook.Sheets(1))
ws.Activate

ws.Range("A1:C1").Value = Array("Sheet", "PivotName", "DataSource")

i = 2

For Each s In ThisWorkbook.Sheets

    For Each pt In s.PivotTables
    
        ws.Cells(i, 1).Value = s.Name
        ws.Cells(i, 2).Value = pt.Name
        ws.Cells(i, 3).Value = pt.SourceData
        i = i + 1
        
    Next pt

Next s

ws.Columns.AutoFit

End Sub
 
Upvote 0
Hi gaj104

Thanks for this. I had to ammend the code slightly but the Pivot table code you gave me was invaluable. Cheers for your help on this. :cool:
 
Upvote 0
Thanks a ton for this.
Source data format is in RC format, trying to get that in the normal format
 
Upvote 0
This was exactly what I needed to make sure I changed the sources in a whole bunch of pivot tables correctly. Thank you.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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