How can I export a PowerPivot table to a new workbook without the attached data model?
Even if I click paste values, Excel makes the file unreasonably large (13MB).
Can I turn this behaviour off?
When you say pasting a Power Pivot table, do you mean copying the table that exists in the data model, that you access through clicking the "Manage" button in the Power Pivot ribbon menu?
Or do you mean copying the values displayed in an Excel pivot table that happens to be backed by a Power Pivot model?
If the former, you can paste the table directly into a new workbook sheet (assuming it has fewer rows than Excel's limit) with no problems and no attachment made to the source workbook's data model.
If the latter, pasting values will bring over only the values, but you have to utilize the right click menu option to do so. If you just CTRL-C CTRL-V the pivot table, and then use the copy-paste context menu to change to values only, then Excel is first creating a copy of the data model in the new workbook to back the pivot table that you are pasting. Then after this action is completed, you are telling it to display values only, but Excel will not delete the data model it's just created to back the pivot table.
I just ran into this problem, it was very easy to resolve. Initially I was trying to paste as values into the destination workbook directly from the source Pivot table which automatically brings the data model across with it.
Simply make a copy of the table by pasting values into the SAME workbook as your data model. Then copy and past the new table into your destination workbook, it will just give you the values and leave the data model behind.
Related
I have a large table in an Excel sheet. I Each time, I copy the table and its slicers to another sheet to analyze data by sorting and filtering. But when filter data in copied sheet, the changes are applied on the original not initial.
What should I do to solve problem and have a fast copy from original sheet to another each time? It should be noted that I can not use "paste value" because it is difficlut for user to set the format each time?
I have 3 sheets with several pivot tables on each and one sheet with the source data. These 4 sheets were copied directly from another workbook. When I copied the worksheets over the source data for each pivot table was still the original source data sheet in the original workbook. Therefore, I changed each pivot table's source to the copied over raw data sheet. Whilst doing this I had to disconnect all the pivot table slicers in order to be able to change the source.
Now, this is where my problem lies; When I go back to reconnect the slicer only one of the pivot tables shows up in the list, when in fact I need to connect the slicer to several. What do I need to do?
Note: I did all of this using a macro that I created so I am open to using macros.
I was able to resolve this issue with the following steps;
Delete all slicers
Change the Table name:
For each pivot table, click on change data source button. The new name should already be in there so just press enter. If you didnt delete all slicers it will throw an error, indicating that it is only identifying other pivot tables with the same datasource now.
Create a new slicer and reconnect to all tables.
Note that step 2 may not be required but that is the workflow that I followed.
I had the same issue with not all pivots showing up and noticed that while the SOURCE was the same in all, the RANGE that I had selected in the source was different. I reset all the ranges in the pivot tables to be the same and all tables now showed up in the slicer for selection.
I had the same issue, and fixed it using the following idea.
Reassign the Pivot Tables' data sources (first define one Pivot Table source, and then copy the PivotCaches to the others):
Sheets("nameofthesheet").Select
ActiveSheet.PivotTables("PivotTable1").ChangePivotCache _
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"name_of_the_table")
ActiveSheet.PivotTables("PivotTable2").CacheIndex = ActiveSheet.PivotTables("PivotTable1").CacheIndex
ActiveSheet.PivotTables("PivotTable3").CacheIndex = ActiveSheet.PivotTables("PivotTable1").CacheIndex
ActiveSheet.PivotTables("PivotTable4").CacheIndex = ActiveSheet.PivotTables("PivotTable1").CacheIndex
Rebuild the Slicers (recording a Macro will be useful!)
Make sure all your pivot table have the same data range, if not change the data range, when all pivot table have the same data range, then it will appear at the connection for the slicer
My problem goes like this:
I have 2 worksheets in 1 workbook which are the "Source Data" and the "Pivot Sheet". Everytime I generate(I generate data every week and it's in macros), data are added to Source Data sheet but the Pivot Table in the Pivot Sheet remains the same. I think it's quite handy if I will still have to Change Data Source everytime I'll generate the report. I want it to automatically adjust it's data source until the last used cell. How to do it? Columns used as Source are from Column C to W Please help! :(
If you create tables (ctrl + t) for your source data and direct your pivot to read those tables, they should automatically expand as new data is entered. Then it should be as simple as Thisworkbook.Worksheets("Pivot").PivotTables("PivotTable1").PivotCache.Refresh (based on the macro recorder)
I have been having problems with a pivot table that uses an external .csv file as its source, particularly with dates in the csv file being treated as text. So, I decided to import the csv file into another worksheet and then force the dates to be recognised as such by reformatting the relevant columns.
The problem I now have is changing the existing pivot table to use the data in the new worksheet instead of an external source. If I click on "Change Data Source" button, the "Select a table or range" option is greyed out. If I continue with external data source and click the Choose Connection button and select the new worksheet I get a pop up that says "The type of connection selected cannot be used to create a PivotTable".
I also tried converting the csv file to xlsx but had a similar problem trying to get the existing pivot table to use it instead of the csv as its source.
It's been a while since you asked, but I had this same problem and just discovered a solution.
Basically, you can use VBA to change pivot tables to a new pivot cache. If the new cache uses the same fields then your layout will be preserved.
Create a new pivot table based on the new data source (it can just be empty).
Click in the new pivot.
In the immediate window type "? selection.pivottable.cacheindex" and press enter.
Note the index number of the pivot cache.
In Excel click in the old pivot which you want to change.
In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
Repeat step 6 for every pivot table which you want to use the new source.
Remove the table you created in step 1.
There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.
Yes, that is an annoying constraint for pivot tables.
Steps to recreate the and change the datasource from .csv to .xls file:
Created a .csv file with headings Name, Birthdate, Sign. Closed the file.
Imported the .csv into a new pivot table PivotTable1 in a new workbook.
Saved the orignal .csv into a new workbook c:\path\to\datasource.xls, naming the worksheet Data and making sure the upper left cell of the data range was in cell A1.
Then I added the following VBA macro and executed it:
Sub getExcelData()
With ActiveSheet.PivotTables("PivotTable1").PivotCache
.Connection = Array( _
Array("ODBC;DSN=Excel Files;"), _
Array("DBQ=c:\path\to\datasource.xls;"), _
Array("DefaultDir=c:\path\to;DriverId=790;MaxBufferSize=2048;PageTimeout=5;") _
)
.CommandText = _
"SELECT `Data$`.Birthdate, `Data$`.Name, `Data$`.Sign" & vbCrLf & _
"FROM `c:\path\to\datasource.xls`.`Data$` `Data$`"
End With
End Sub
The .CommandText syntax for this driver is horribly picky and not at all smart.
YMMV with this code in 2010 or later and/or with different drivers. Date and numeric data are notoriously ill-handled even in later versions of Excel data drivers. I generally make sure that every cell in a numeric or date field has a valid value, or at the very least every cell in the first row of data, before importing.
This helps but for those who dont know where is immediate window you need to go to developer tab and get in the Visual basic Macro window and press Ctrl+G it will open the immediate window at the bottom. Original answered by mendosi It's been a while since you asked, but I had this same problem and just discovered a solution. Basically, you can use VBA to change pivot tables to a new pivot cache. If the new cache uses the same fields then your layout will be preserved.
Create a new pivot table based on the new data source (it can just be empty).
Click in the new pivot.
In the immediate window type "? selection.pivottable.cacheindex" and press enter.
Note the index number of the pivot cache.
In Excel click in the old pivot which you want to change.
In the immediate window type "selection.pivottable.cacheindex = x" where x is the index number you noted in step 4.
Repeat step 6 for every pivot table which you want to use the new source.
Remove the table you created in step 1.
There may to change all tables from one cache to another in a single step, but it's probably not something you need to do often.
Since I'm a new member, I can't add comment nor add vote.
Anyway as I found this page because I have the same problem,
to me, the answer from Ines is correct and the easiest one.
Excel 2010:
Customize The Ribbon....
Commands not in the Ribbon...
PivotTable and PivotChart Wizard...
Add number-3 as new menu (I choose as new menu in the INSERT tab)
Click the Pivot Table which data source need to be changed from external connection to a range or table in the active worksheet.
Click number-3 menu
Click "back" twice
Choose Microsoft Excel List or Database radio button
click "next" then fill the range or the named range in the range-box
Click FINISH
There I can finally change it from external data to a range
Thank you very much, Ines.
(Don't know why someone down voted you).
I have a workbook (wkbk1) that has a sheet with eight different query tables (a.k.a. data tables) on it -- NOT PIVOT TABLES. They all point to the same external Excel workbook (wkbk2) for their data which is a single sheet with a group of named ranges.
The data for each table in wkbk1 comes from a named range in wkbk2. How can I copy the sheet of eight different tables (from wkbk1) to other workbooks (wkbk3, wkbk4, etc)?
Is it even possible for the query table and its data connection to transfer with the sheet? So far I can't do it manually (no coding). If coding is required I'm fine with that, just need help with it. I have intermediate VBA coding experience.
I'm using Excel 2007/2010.
In Excel 2010, I right click on the sheet tab and choose Move or Copy. Select the destination workbook and check "Create a Copy". The new sheet has the QueryTable on it and refreshes as expected.
So I think copying the sheet will copy the QueryTable and all its properties.
My QueryTable used MSQuery and pointed to another Excel workbook.