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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,380
Members
448,955
Latest member
BatCoder

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
Back
Top