View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary Brown Gary Brown is offline
external usenet poster
 
Posts: 178
Default Display the source for a pivot table page field

As far as I know, you can't get the 'original' source name because you have
replaced the header with another name. The original header information
doesn't seem to any longer be available. I tested a number of different
scenerios and couldn't come up with anything. This is XL2000. Maybe it's
changed since that version but I doubt it.
Sorry.
--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"Jayashree Krishna" wrote:

Hi,

Actually, I am giving different name for the page field, say "Cost" in
source field will be displayed as "Item Price" in the page field. Is there
any way to get the corresponding source field name from the page field
properties?
Thanks,
Krishna


"Gary Brown" wrote:

The name you see in the Page Field is the name you see in the heading of the
souce data.
--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"Jayashree Krishna" wrote:

Hi,

I tried this and it helps in letting the developer know the souce.

I want the user to know the source field for each page field .(like we can
get the source column for the Data Field of the pivot table if you click on
the field setting tab) . Is there any way that the user can simply select
some property to know the source field?
Thanks,
Krishna


"Gary Brown" wrote:

Try this...
Option Explicit
'


'/================================================/
Sub Pivot_Properties()
'Creates a worksheet within the current workbook
' listing pivot table information
'Creates a comment on each pivot table containing an
' abbreviated version of that information
Dim aryHiddensheets()
Dim blnColFields As Boolean, blnShowValues As Boolean
Dim blnMakeComment As Boolean
Dim d As Double, c As Double
Dim i As Long, z As Long, iPtCount As Long
Dim x As Long, y As Long, w As Long
Dim iFieldsCount As Long
Dim iRow As Long, iColumn As Long
Dim iWorksheets As Long
Dim objCalcItem As Object
Dim objCubeFld As Object
Dim objPvtField As Object
Dim objOutputArea As Object
Dim objSheet As Object
Dim strAnswer As String, strComment As String
Dim strResultsTableName As String
Dim varAnswer As Variant
Dim varPvtField As Variant, varPivotItem As Variant

On Error Resume Next

'/- - - - Variables - - - - - - - -
strResultsTableName = "PivotTableProperties"
strAnswer = ""
strComment = ""
iRow = 1
iColumn = -2
iPtCount = 0
blnColFields = True
blnShowValues = True
blnMakeComment = False
'/- - - - End Variables - - - - - -

varAnswer = _
MsgBox("Show Selected Values for each field?" & _
vbCr & vbCr & _
"Select 'No' to only show Heading names", _
vbInformation + vbYesNoCancel + vbDefaultButton2, _
"Show Values for each field...")

If varAnswer = vbNo Then
blnShowValues = False
End If

If varAnswer = vbCancel Then
MsgBox "This process has been canceled.", _
vbInformation + vbOKOnly, "Warning..."
Exit Sub
End If

'check for an active workbook
'no workbooks open, so create one
If ActiveWorkbook Is Nothing Then
Workbooks.Add
End If

'Count number of worksheets in workbook
iWorksheets = ActiveWorkbook.Sheets.Count

'redim array
ReDim aryHiddensheets(1 To iWorksheets)

x = 0
y = 0
For Each objSheet In ActiveWorkbook.Sheets
y = y + 1
If objSheet.Visible < True Then
x = x + 1
aryHiddensheets(x) = objSheet.name
objSheet.Visible = True
End If
Next objSheet

'Check for duplicate Worksheet name
i = ActiveWorkbook.Sheets.Count
For x = 1 To i
If UCase(Worksheets(x).name) = _
UCase(strResultsTableName) Then
Worksheets(x).Activate
If Err.Number = 9 Then
Exit For
End If
'turn warning messages off
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
'turn warning messages on
Application.DisplayAlerts = True
Exit For
End If
Next

'Add new worksheet at end of workbook
' where results will be located
Worksheets.Add.Move after:=Worksheets(Worksheets.Count)

'Name the new worksheet and set up Titles
ActiveWorkbook.ActiveSheet.name = strResultsTableName
ActiveWorkbook.ActiveSheet.Range("A1").value = _
"Pivot Table Information"
ActiveWorkbook.ActiveSheet.Range("A1").Font.Bold
ActiveWorkbook.ActiveSheet.Range("A1").Font.Size = 16
ActiveWorkbook.ActiveSheet.Range("A1").Font.Underl ine = _
xlUnderlineStyleSingle

iWorksheets = ActiveWorkbook.Sheets.Count

Set objOutputArea = _
ActiveWorkbook.Sheets(strResultsTableName).Range(" A1")
iRow = iRow + 1

'Go through one Worksheet at a time
For x = 1 To iWorksheets
'Go to Next Worksheet
Worksheets(x).Activate
'Initialize formula and text/value count variables
i = ActiveSheet.PivotTables.Count
iPtCount = iPtCount + i
strComment = ""
If i 0 And _
UCase(ActiveSheet.name) < _
UCase(strResultsTableName) Then
blnMakeComment = True
With ActiveSheet
For z = 1 To i
strComment = ""
iColumn = iColumn + 2
ActiveWorkbook.Sheets(strResultsTableName). _
Columns(iColumn + 1) _
.NumberFormat = "@"

With .PivotTables(z)
objOutputArea.Offset(iRow, iColumn) = _
"Pivot Table Name: " & .name
objOutputArea.Offset(iRow, iColumn).Font.Size = 12
objOutputArea.Offset(iRow, _
iColumn).Font.Underline = _
xlUnderlineStyleSingle
objOutputArea.Offset(iRow, iColumn).Font.Bold
iRow = iRow + 1
strComment = strComment & "Pivot Table Name: " & _
.name & Chr(10)

objOutputArea.Hyperlinks.Add _
Anchor:=objOutputArea.Offset(iRow, iColumn), _
Address:=ActiveWorkbook.FullName, _
TextToDisplay:="Location/Name (Workbook): " & _
ActiveWorkbook.FullName
iRow = iRow + 1

objOutputArea.Hyperlinks.Add _
Anchor:=objOutputArea.Offset(iRow, iColumn), _
Address:=ActiveWorkbook.FullName, _
SubAddress:= _
Left(.SourceData, InStr(.SourceData, "!") - 1) & _
"!" & _
Range_RC2A1(Right(.SourceData, Len(.SourceData) - _
InStr(.SourceData, "!"))), _
TextToDisplay:= _
"Data Source of Pivot Table (Worksheet): " & _
Left(.SourceData, _
InStr(.SourceData, "!") - 1) & "!" & _
Range_RC2A1(Right(.SourceData, Len(.SourceData) - _
InStr(.SourceData, "!")))
iRow = iRow + 1
strComment = strComment & _
"Data Source of Pivot Table (Worksheet): " & _
Left(.SourceData, InStr(.SourceData, _
"!") - 1) & "!" & _
Range_RC2A1(Right(.SourceData, Len(.SourceData) - _
InStr(.SourceData, "!"))) & Chr(10)

objOutputArea.Offset(iRow, iColumn) = _
"Data Source - CacheIndex = " & .CacheIndex
iRow = iRow + 1
strComment = strComment & _
"Data Source - CacheIndex = " & _
.CacheIndex & Chr(10)

objOutputArea.Hyperlinks.Add _
Anchor:=objOutputArea.Offset(iRow, iColumn), _
Address:=ActiveWorkbook.FullName, _
SubAddress:=Chr(39) & ActiveSheet.name & _
Chr(39) & "!" & _
.TableRange2.Address, _
TextToDisplay:= _
"Pivot Table Location (Worksheet): " & _
ActiveSheet.name & "!" & _
.TableRange2.Address
iRow = iRow + 1
strComment = strComment & _
"Pivot Table Location (Worksheet): " & _
ActiveSheet.name & "!" & _
.TableRange2.Address & Chr(10) & Chr(10) & Chr(10)

objOutputArea.Offset(iRow, iColumn) = _
"Row Information - Order (#)"
objOutputArea.Offset(iRow, iColumn).Font.Bold
iRow = iRow + 1

objOutputArea.Offset(iRow, iColumn) = _
"Row Heading Field(s): "
iRow = iRow + 1
For Each varPvtField In .RowFields
For w = 1 To .RowFields.Count
If varPvtField.name = .RowFields.Item(w) Then
objOutputArea.Offset(iRow, iColumn) = _
" - " & " ( " & _
varPvtField.Position & " ) " & _
varPvtField.name
End If
Next w

c = 0
If varPvtField.name = "Data" Then
If .ColumnFields.Count = 0 Then
blnColFields = False
End If
If .RowFields.Count = 1 Then
objOutputArea.Offset(iRow, iColumn) = _
" - " & varPvtField.name & _
" *** [No Row Fields Selected]"
Else
objOutputArea.Offset(iRow, iColumn) = _
" - " & varPvtField.name
End If
End If
iRow = iRow + 1

For Each varPivotItem In .PivotFields( _
varPvtField.name).PivotItems
If varPivotItem.Visible Then
If blnShowValues = True Then
If c = 0 Then
objOutputArea.Offset(iRow, iColumn) = _
" Selected - " & _
varPivotItem.name
Else
objOutputArea.Offset(iRow, iColumn) = _
" - " & _
varPivotItem.name
End If
iRow = iRow + 1
End If
c = 1
End If
Next varPivotItem

Next varPvtField
If .RowGrand = True Then
objOutputArea.Offset(iRow, iColumn) = _