Pivot Table Data Source

vandido626

New Member
Joined
Jul 19, 2007
Messages
8
I'm working with a pivot table that is linked to an access db. I would like know what the source data is. Can someone let me know what I have to do? I have tried viewing microsoft query but since its a pivot table the option is faded out.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

KWMSeattle

Board Regular
Joined
Aug 23, 2006
Messages
149
I haven't tried this with a pivot linking to an Access database, but here is some lame code I put together to give me the server name and cube name for OLAP cube pivots.

Code:
Sub GetPivotSource()
Dim pvt As PivotTable, ServerName As String, CubeName As String
 
On Error Resume Next
Set pvt = ActiveCell.PivotTable
    If Err.Number <> 0 Then
        MsgBox "Active cell is not in a pivot table", vbOKOnly, "Pivot Source"
        Exit Sub
    End If
 
    ServerName = Mid(pvt.PivotCache.Connection, 64, Len(pvt.PivotCache.Connection) - 132)
    CubeName = Mid(pvt.PivotCache.Connection, 92, Len(pvt.PivotCache.Connection) - 136)
 
    If ServerName = "" Then
        MsgBox "Pivot table data comes from an Excel table", vbInformation
    Else
        'Show pivot table connection details
        MsgBox "Server:  " & ServerName & vbCr & "Cube:  " & CubeName, vbOKOnly, "Pivot Source"
    End If
 
End Sub
 

vandido626

New Member
Joined
Jul 19, 2007
Messages
8
I haven't tried this with a pivot linking to an Access database, but here is some lame code I put together to give me the server name and cube name for OLAP cube pivots.

Code:
Sub GetPivotSource()
Dim pvt As PivotTable, ServerName As String, CubeName As String
 
On Error Resume Next
Set pvt = ActiveCell.PivotTable
    If Err.Number <> 0 Then
        MsgBox "Active cell is not in a pivot table", vbOKOnly, "Pivot Source"
        Exit Sub
    End If
 
    ServerName = Mid(pvt.PivotCache.Connection, 64, Len(pvt.PivotCache.Connection) - 132)
    CubeName = Mid(pvt.PivotCache.Connection, 92, Len(pvt.PivotCache.Connection) - 136)
 
    If ServerName = "" Then
        MsgBox "Pivot table data comes from an Excel table", vbInformation
    Else
        'Show pivot table connection details
        MsgBox "Server:  " & ServerName & vbCr & "Cube:  " & CubeName, vbOKOnly, "Pivot Source"
    End If
 
End Sub

says its from an excel table but im sure its not........still nice code that I can use down the line...thanks
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,782
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
If you need to know which tables or queries, you can right-click the table, choose Pivot Table Wizard, press the Back button and then the 'Get Data...' button. If you need to know which database it is connected to, then you need to look at the PivotCache connection in code.
 

vandido626

New Member
Joined
Jul 19, 2007
Messages
8
If you need to know which tables or queries, you can right-click the table, choose Pivot Table Wizard, press the Back button and then the 'Get Data...' button. If you need to know which database it is connected to, then you need to look at the PivotCache connection in code.

perfect!

so easy that it makes me feel a bit embarrassed

thanks
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,951
Messages
5,834,545
Members
430,295
Latest member
amdis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top