Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default Pivot Table Data Ranges

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default Pivot Table Data Ranges

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table from multiple ranges? (Revisited) Steve Vincent Excel Discussion (Misc queries) 4 February 20th 07 08:34 PM
Pivot Table-Multiple Consolidation Ranges Rach Excel Discussion (Misc queries) 3 January 12th 07 12:46 AM
Pivot table/chart - can I use data ranges? why will it not group d Forrest Charts and Charting in Excel 0 January 10th 06 07:26 PM
Pivot Table - consolidating ranges (again) xman Excel Discussion (Misc queries) 3 September 18th 05 02:17 PM
creating a pivot table w/ ranges from 2 worksheets tl Excel Discussion (Misc queries) 1 August 20th 05 07:16 PM


All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"