Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Pivot Table - Source Data Information


Can anyone help me with the vba code needed to determine a pivot table's
source data broken down into its individual components?

1. Full Directory Path
2. Full Workbook Name
3. Sheet Name
4. Range Address
--
Thank you for your help.

MSweetG222
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Pivot Table - Source Data Information


I'm not sure I think this is the BEST way, but it works.

Option Explicit

Sub FindPivot()

Dim myPivot As Excel.PivotTable
Dim mySourceData As String
Dim mySheetName As String
Dim myRangeAddress As String
Dim myVal As Long
Dim myWS As Excel.Worksheet
Dim myWB As Excel.Workbook
Dim mySelection As Excel.Range
Dim myWBPath As String
Dim myWBName As String
Dim myWSName As String
Dim aWS As Excel.Worksheet
Dim myAddress As String

Set aWS = ActiveSheet
Set mySelection = Selection
Application.ScreenUpdating = False

For Each myPivot In ActiveSheet.PivotTables
Debug.Print myPivot.Name, myPivot.SourceData
mySourceData = myPivot.SourceData
myVal = InStr(mySourceData, "!")
If myVal 0 Then
Application.Goto (mySourceData)
myRangeAddress = Selection.Address
Set myWS = Selection.Parent
Set myWB = myWS.Parent
myWBPath = myWB.FullName
myWBName = myWB.Name
myWSName = myWS.Name
Debug.Print myPivot.Name, myWBPath, myWBName, myWSName, myRangeAddress


End If
Next myPivot

aWS.Select
Application.ScreenUpdating = True

End Sub

HTH,
Barb Reinhardt

"MSweetG222" wrote:

Can anyone help me with the vba code needed to determine a pivot table's
source data broken down into its individual components?

1. Full Directory Path
2. Full Workbook Name
3. Sheet Name
4. Range Address
--
Thank you for your help.

MSweetG222

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Pivot Table - Source Data Information


Barb.

Thanks for your help. I will give it a try. :)

MSweetG222


"Barb Reinhardt" wrote:

I'm not sure I think this is the BEST way, but it works.

Option Explicit

Sub FindPivot()

Dim myPivot As Excel.PivotTable
Dim mySourceData As String
Dim mySheetName As String
Dim myRangeAddress As String
Dim myVal As Long
Dim myWS As Excel.Worksheet
Dim myWB As Excel.Workbook
Dim mySelection As Excel.Range
Dim myWBPath As String
Dim myWBName As String
Dim myWSName As String
Dim aWS As Excel.Worksheet
Dim myAddress As String

Set aWS = ActiveSheet
Set mySelection = Selection
Application.ScreenUpdating = False

For Each myPivot In ActiveSheet.PivotTables
Debug.Print myPivot.Name, myPivot.SourceData
mySourceData = myPivot.SourceData
myVal = InStr(mySourceData, "!")
If myVal 0 Then
Application.Goto (mySourceData)
myRangeAddress = Selection.Address
Set myWS = Selection.Parent
Set myWB = myWS.Parent
myWBPath = myWB.FullName
myWBName = myWB.Name
myWSName = myWS.Name
Debug.Print myPivot.Name, myWBPath, myWBName, myWSName, myRangeAddress


End If
Next myPivot

aWS.Select
Application.ScreenUpdating = True

End Sub

HTH,
Barb Reinhardt

"MSweetG222" wrote:

Can anyone help me with the vba code needed to determine a pivot table's
source data broken down into its individual components?

1. Full Directory Path
2. Full Workbook Name
3. Sheet Name
4. Range Address
--
Thank you for your help.

MSweetG222

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 data source FerrariWA Excel Discussion (Misc queries) 1 July 6th 09 05:48 PM
Code that will rerun or refresh a pivot table (after new data ispasted into the original Pivot Table's Source Range) Mike C[_5_] Excel Programming 3 February 15th 08 06:22 AM
Pivot Table Data Source SusanJane sjl Excel Discussion (Misc queries) 1 March 1st 07 07:02 PM
Pivot table data source Randy Harris Excel Discussion (Misc queries) 1 March 1st 06 07:16 AM
Pivot Table data source "data source contains no visible tables" Jane Excel Worksheet Functions 0 September 29th 05 08:28 PM


All times are GMT +1. The time now is 07:26 PM.

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"