Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Is there any nifty way to find all the Data Ranges referred to in all the
Pivot tables in a file. I needed to change the ranges referred to and want to make sure I got them all. Thanks |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This macro lists the source data range(s) for every pivot table in the active
workbook on a new sheet: Sub ListAllSourceData() 'List source data ranges in all pivot tables on a new sheet On Error Resume Next Application.ScreenUpdating = False Dim NewWS As Worksheet, StartWS As Worksheet Dim pt As PivotTable Dim ws As Worksheet Dim ii As Long, jj As Long Dim sdArray Set StartWS = ActiveSheet 'Add a new worksheet to the current workbook at the end. Worksheets.Add.Move after:=Sheets(Sheets.Count) Set NewWS = ActiveSheet jj = 0 'Look at every pivot table on every sheet For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables sdArray = pt.SourceData 'If a multiple consolidation range pivot table, 'SourceData is an array. If IsArray(sdArray) Then For ii = LBound(sdArray) To UBound(sdArray) jj = jj + 1 NewWS.Cells(jj, 1) = pt.Name NewWS.Cells(jj, 2) = sdArray(ii) Next ii Else jj = jj + 1 NewWS.Cells(jj, 1) = pt.Name NewWS.Cells(jj, 2) = pt.SourceData End If Next pt Next ws StartWS.Activate 'Free object variables Set StartWS = Nothing Set NewWS = Nothing Application.ScreenUpdating = True End Sub Paste the code in a VBA module in your workbook. To run it from a worksheet, press Alt-F8 (or select Tools Macro Macros). Select ListAllSourceData, then click Run. If you are new to macros, this link to Jon Peltier's site may be helpful: http://peltiertech.com/WordPress/200...e-elses-macro/ Hope this helps, Hutch "Darby" wrote: Is there any nifty way to find all the Data Ranges referred to in all the Pivot tables in a file. I needed to change the ranges referred to and want to make sure I got them all. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot table from multiple ranges? (Revisited) | Excel Discussion (Misc queries) | |||
Pivot Table-Multiple Consolidation Ranges | Excel Discussion (Misc queries) | |||
Pivot table/chart - can I use data ranges? why will it not group d | Charts and Charting in Excel | |||
Pivot Table - consolidating ranges (again) | Excel Discussion (Misc queries) | |||
creating a pivot table w/ ranges from 2 worksheets | Excel Discussion (Misc queries) |