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)
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?
Every month, I run a massive Scorecard report. The raw data contains 13 workbooks that are exported as .csv files.
I use Power Query to manipulate and Append this data into 4 different worksheets.
To keep things clean, I then use a Macro to move the 4 Data Arrays into a Scorecard Workbook (which is shared with the team)
The Scorecard Workbook has 4 tabs with the Data Sheets: wsTotalUS, wsCombined, wsDFCoreMkts, wsNovCoreMkts.
The 4 Data Sheets to create 4 different Pivot Caches.
wsTotalUS has a Pivot Table on Sheet5
wsCombined has a Pivot Table on Sheets 6-13
wsDFCoreMkts has a Pivot Table on Sheet 14
wsNovCoreMkts has a Pivot Table on Sheet 15
Each month the data Rows can change (The Columns will always be the same - “A:AP”)
I have researched how to dynamically update pivot tables. I know some articles suggest changing the source data into a Table. I would like to avoid this due to the amount of time it would take to move the Data over to the Scorecard.
For example: wsTotalUS has 47,707 rows & wsCombined has 123,153 rows
One article I found had the code written on the Source Data Sheet as a Private Sub Worksheet_Deactivate().
However, this would only use one Data Sheet, and update all of the Pivot Tables in the workbook when you switch from the data sheet.
How to Dynamically Update All Pivot Tables Data Source in Excel
I found these articles, but they one only refers to one Data Sheet and one Pivot Table.
How to Automatically Update a Pivot Table Range in Excel
Dynamically Change a Pivot Table's Data Source Range with This VBA Code
This article uses the Worksheet_SelectionChange event. But again, only one Data Sheet is implied here.
Refresh Pivot Tables Automatically when Source Data Changes
How do I go about dynamically updating 4 different PivotCaches within a workbook?
Should I just run 4 separate sub routines?
UPDATED:
Based on Tim's suggestion:
Under Formulas -> Named Range:
TotalUS =OFFSET('Total US'!$A$1,0,0, COUNTA('Total US'!$A:$A),COUNTA('Total US'!$1:$1))
Then go to the Pivot Table that references this data, Change Data Source = TotalUS
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
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.
I needed some guidance from your more experience excel pros. I have two sheets in my excel file.
Data
Pivot Data
I have my data in the "Data" sheet and I have created a Pivot sheet for sheet Data.
Everyweek, I delete my data in the Data sheet and paste new data.With this, my rows become more. to update my pivots, I need to go to data source and update it so it include all the rows.
Is there something I can do or write so the pivots automatically adjust to the size of the new paste data in the Data sheet?
If before deleting the data, it was on row 400, I then paste new data and the row number is now 800, how can I automate this process rather than going to each pivot and updating manually to the new row number so it captures all the new data?
Change your Data Source range to exclude row numbers, so say:
Sheet3!$A:$D
instead of:
Sheet3!$A1:$D400
This will however introduce a row in your PT of (blank) (if not already present there), though you might filter to hide that row.