LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Macro Needed for Pivot Table

In a General Code Module:
(This will create a sheet called "Pivot Listing". It will also delete it if
it already exists. If this would cause a problem in your workbook, change
the name.)

Public Sub ListPivotTables()
On Error GoTo ErrHandler

Dim wks As Worksheet
Dim pvt As PivotTable
Dim wksOutput As Worksheet
Dim r As Long
Dim strOutputSheet as string

strOutputSheet = "Pivot Listing"

On Error Resume Next
Application.DisplayAlerts = False
ThisWorkbook.Worksheets(strOutputSheet).Delete
Application.DisplayAlerts = True
On Error GoTo ErrHandler

Set wksOutput = ThisWorkbook.Sheets.Add
wksOutput.Name = strOutputSheet
wksOutput.Range("A1") = "Sheet Name"
wksOutput.Range("B1") = "Pivot Name"
wksOutput.Range("C1") = "Source Data"
wksOutput.Range("A1:C1").Font.Bold = True

r = 2
For Each wks In ThisWorkbook.Worksheets
For Each pvt In wks.PivotTables
wksOutput.Cells(r, 1) = wks.Name
wksOutput.Cells(r, 2) = pvt.Name
wksOutput.Cells(r, 3) = pvt.SourceData
r = r + 1
Next pvt
Next wks
Columns("A:C").EntireColumn.AutoFit

ExitHe
Exit Sub
ErrHandler:
MsgBox "Cancelling: " & Err.Number & " " & Err.Description, vbOKOnly,
"ERROR!"
Resume ExitHere
End Sub

HTH,
--
George Nicholson

Remove 'Junk' from return address.


wrote in message
ups.com...
All,

I have many pivot tables on many sheets in a single workbook. Each of
these may have a diffrent data source pointing to MS SQL.

What I would like is a Macro to run which tells me something like this:

SheetName PivotTable Name Data Souce

Sheet1 PT1 DB.my.mytable

Is there an easy way to loop through this?

I do not want to go through over 50 Pivot Tables and the wizard to get
this info. Too time consuming.

Thanks in advance for any help or suggestions.

Doug Fast



 
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
Calculation needed maybe a pivot table - Thank you Eduardo Excel Discussion (Misc queries) 2 November 5th 08 04:45 PM
Pivot Table Help Needed!!!! [email protected] Excel Discussion (Misc queries) 3 July 25th 08 01:52 PM
Pivot Table Assistance Needed Barb R. Excel Worksheet Functions 4 May 11th 05 05:11 PM
Pivot table subtotals help needed anthony Excel Discussion (Misc queries) 2 April 26th 05 12:47 PM
Pivot table help needed Sajith Excel Programming 0 September 27th 04 05:13 PM


All times are GMT +1. The time now is 03:21 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"