Pivot Tables - Change source from internal to external
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Pivot Tables - Change source from internal to external
I have a boss who wants to re-architect all of the corporate reporting.
Currently this is done via Pivot Tables with data sources in the same workbook.
He wants to Change the data source to be another workbook on the network.
Via the GUI, Excel disables the external connections option for existing pivot tables.
So I tried to use the VBA "ChangeConnection" method to do so. That bombed on a 1004 error.
So it appears there is no other way to do this other than deleting the old one and re-creating a new pivot table ?
Am I correct ?
Currently this is done via Pivot Tables with data sources in the same workbook.
He wants to Change the data source to be another workbook on the network.
Via the GUI, Excel disables the external connections option for existing pivot tables.
So I tried to use the VBA "ChangeConnection" method to do so. That bombed on a 1004 error.
So it appears there is no other way to do this other than deleting the old one and re-creating a new pivot table ?
Am I correct ?
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Pivot Tables - Change source from internal to external
I don't think you need to use the External Connections option.
If you open the source file on the network, and you open the current file with the pivot table, then go to the Change Data Source dialog, clear the current source and while the cursor is flashing in the Table/Range box, switch to the new source (that you opened from the network) and highlight the range in this file. Click on OK and the pivot will now accept the new source and location.
If you open the source file on the network, and you open the current file with the pivot table, then go to the Change Data Source dialog, clear the current source and while the cursor is flashing in the Table/Range box, switch to the new source (that you opened from the network) and highlight the range in this file. Click on OK and the pivot will now accept the new source and location.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 5StarLounger
- Posts: 817
- Joined: 24 Jan 2010, 15:56
Re: Pivot Tables - Change source from internal to external
Or click in the pivot table, press Alt+DP, step back to step 1 of the wizard and choose 'External data' there.
Regards,
Rory
Rory
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
Thanks guys....it worked when I opened the data source workbook.
However, it is interesting: One can have a connection established to a workbook or a direct reference to the same workbook in a different pivot table.
I imagine the direct reference is better ?
Anyone test this one way or the other ?
However, it is interesting: One can have a connection established to a workbook or a direct reference to the same workbook in a different pivot table.
I imagine the direct reference is better ?
Anyone test this one way or the other ?
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Pivot Tables - Change source from internal to external
Just my opinion, but if the source is a range in Excel (no matter it being in the same WB as the pivot or external), it is better to have a direct reference. If the source is anything other than a range it is better to go by data connection.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
thanks Rudi - but the huge issue is one of dependence: the direct connect requires that the data source workbook be open when the pivot table workbook is refreshed !!!
That is not required with a connection.
However, in this case, we don't want the users refreshing the data......so this is perfect.
That is not required with a connection.
However, in this case, we don't want the users refreshing the data......so this is perfect.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Pivot Tables - Change source from internal to external
Glad to have helped resolve the query.
Regarding your statement that "the direct connection requires that the data source workbook be open when the pivot table workbook is refreshed..."
This is not true. If I open a workbook containing a pivot whose source is in a closed workbook, (as long as I have acknowledged that the workbook can update external links), then, on refreshing the pivot, the data updates.
Cheers
Regarding your statement that "the direct connection requires that the data source workbook be open when the pivot table workbook is refreshed..."
This is not true. If I open a workbook containing a pivot whose source is in a closed workbook, (as long as I have acknowledged that the workbook can update external links), then, on refreshing the pivot, the data updates.
Cheers
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
"RE: as long as I have acknowledged that the workbook can update external links), then, on refreshing the pivot, the data updates. "
Not with source data as a TABLE reference.
result in 2010: "Invalid Reference".
Open the data workbook and that goes away.
Likely a bug.
Not with source data as a TABLE reference.
result in 2010: "Invalid Reference".
Open the data workbook and that goes away.
Likely a bug.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Pivot Tables - Change source from internal to external
TX. Never tested with a table.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 5StarLounger
- Posts: 817
- Joined: 24 Jan 2010, 15:56
Re: Pivot Tables - Change source from internal to external
Tables are effectively dynamic ranges and, as such, can't be resolved unless the parent workbook is open.
Regards,
Rory
Rory
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Pivot Tables - Change source from internal to external
TX Rory; that makes sense
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
Correct, however this is a bug/limitation in that the Excel architects could have used the range stored in the Names section and then returned that range when requested by another workbook. All tables have a Named reference containing the current range.rory wrote:Tables are effectively dynamic ranges and, as such, can't be resolved unless the parent workbook is open.
Could-a, Should-a, Would-a.
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
More bugs: when trying to create a new Pivot Table referencing the tablename, you must first select some cells in the worksheet where the table resides.
Once that is done, remove the cell references and replace with the Tablename. Viola.....Excel changes the reference completely.
Try typing it in directly: Invalid Reference is thrown.
Once that is done, remove the cell references and replace with the Tablename. Viola.....Excel changes the reference completely.
Try typing it in directly: Invalid Reference is thrown.
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
Even more bugs: Pivot table "RefreshTable" method seems to fail.....silently.
Can anyone tell me the difference between:
PivotCache.Refresh and PivotTable.RefreshTable
Can anyone tell me the difference between:
PivotCache.Refresh and PivotTable.RefreshTable
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Pivot Tables - Change source from internal to external
As far as I can tell there is no difference - see your thread PivotTable - RefreshTable vs. Refresh PivotCache from last year.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
Thanks for reminding me Hans.
Still, with a TABLE as the source data reference, an open workbook does not seem to get it's Pivottables refreshed via a RefreshTable method call from another workbook.
I noticed that the RefreshTable method does return a true/false return value whereas Refresh.PT.PivotCache does not.
I have never tested the return value....I guess I should now.
However, does a false return indicate the pivottable has completed the refresh... or some other problem ?
Still, with a TABLE as the source data reference, an open workbook does not seem to get it's Pivottables refreshed via a RefreshTable method call from another workbook.
I noticed that the RefreshTable method does return a true/false return value whereas Refresh.PT.PivotCache does not.
I have never tested the return value....I guess I should now.
However, does a false return indicate the pivottable has completed the refresh... or some other problem ?
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Pivot Tables - Change source from internal to external
I don't know the exact ins and outs of RefreshTable - I hope someone else knows more about it.
The PivotTable.RefreshTable method returns True if the table was updated successfully, False otherwise. If False, it doesn't provide any information as to why the update failed.
To confuse matters even further, the PivotTable object also has an Update method. I have no idea what that one does - it doesn't update the pivot table when the source data have been changed.
The PivotTable.RefreshTable method returns True if the table was updated successfully, False otherwise. If False, it doesn't provide any information as to why the update failed.
To confuse matters even further, the PivotTable object also has an Update method. I have no idea what that one does - it doesn't update the pivot table when the source data have been changed.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 817
- Joined: 24 Jan 2010, 15:56
Re: Pivot Tables - Change source from internal to external
It updates the pivot table if you have it set to defer updating the layout (the Manualupdate = true option in code).HansV wrote: To confuse matters even further, the PivotTable object also has an Update method. I have no idea what that one does - it doesn't update the pivot table when the source data have been changed.
Regards,
Rory
Rory
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 584
- Joined: 12 Jul 2012, 10:34
Re: Pivot Tables - Change source from internal to external
Thanks Rory, but I think the Update method only changes/updates the pivotfields settings and properties and the pivottable layout (which fields are row, column, page, etc). I don't think it has anything to do with the refresh of the data source.
An interesting observation:
if RefreshTable and Pivotcache Refresh were indeed the same methods functionally, why would one have a return value and the other none ?
An interesting observation:
if RefreshTable and Pivotcache Refresh were indeed the same methods functionally, why would one have a return value and the other none ?