Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro Needed for Pivot Table

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

  #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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro Needed for Pivot Table

George,

This is great, thanks so much. Are other things that I could bring
back as well? I figure why not go all the way. Like Row Count, Memory
usage, ect.

Doug

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro Needed for Pivot Table


George and all,

Sorry to be a pest my data source is showing this:
DRIVER=SQL Server;SERVER=AMLBR06;UID=u777064;APP=Microsoft®
Query;WSID=NYCTO1X401169;DATABASE=BPA;Network=DBMS SOCN;QueryLogFile=Yes;Trusted_Connection=Yes

Vs what I was hoping for was this BPA.DF.My_Base_Table

This is connecting to a MS SQL Database.

Doug

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
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 05:27 AM.

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

About Us

"It's about Microsoft Excel"