Pivot and automatic inclusion of new row nr data in Excel - excel

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.

Related

Why any changes in copied table applies on the original in Excel?

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?

How to Dynamically update multiple PivotCaches in one workbook using VBA?

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

What formula would I use to make a column automatically populate in excel when new data is loaded into a worksheet?

I am creating a report in Excel with 3 separate worksheets, the main one where data is reported and calculated, one for new data and one for old data. I want values in one column in the main worksheet to update when new information is moved into the new data worksheet but still see values that were in the old data that may have dropped off the new list.
Connect to an Excel table or range
Click the Data tab, then > From Table/Range.
https://support.office.com/en-ie/article/connect-to-an-excel-table-or-range-power-query-67538004-cd12-4b61-9cee-8720db1c7136

Column header validation with different sheets using macros

In Excel, I have 4 column headers (Id, Name, Age, Place).
I have 3 Excel worksheets with same column headers and different data.
I want to make a consolidated worksheet and the constraint is I have to check whether the column header is the same in all 3 worksheets and move it into the consolidated worksheet.
In the 1st worksheet I have values in the first row.
In 2nd worksheet, the first row is empty and the second row has data.
In 3rd worksheet, the first and second rows are empty and the 3rd row has data.
The 4th worksheet is the consolidated one. I want all 3 worksheet's data in this sheet.
How to do it with macros in vba?
There's built-in functionality for data consolidation.
You'll need to move your data so it's all on the same row but in the end will probably be much easier than writing code from scratch.
How to consolidate
Follow these steps to consolidate several worksheets into a master worksheet:
If you haven't already, set up the data in each constituent sheet by doing the following:
Ensure that each range of data is in list format. Each column must have a label (header) in the first row and contain similar data. There must be no blank rows or columns anywhere in the list.
Put each range on a separate worksheet, but don't enter anything in the master worksheet where you plan to consolidate the data. Excel will do this for you.
Ensure that each range has the same layout.
In the master worksheet, click the upper-left cell of the area where you want the consolidated data to appear.
Note: To avoid overwriting existing data in the master worksheet, ensure that you leave enough cells to the right and below this cell for the consolidated data.
Click Data → Consolidate (in the Data Tools group).
In the Function box, click the summary function that you want Excel to use to consolidate the data. The default function is SUM.
Here is an example in which three worksheet ranges have been chosen:
Select your data.
More information and the remaining instructions are at the source.
If you want to automate the process, record a macro as you performs the necessary steps and then you can edit as required.
See: Recording a Macro to Generate Code as well as Revising Recorded Visual Basic Macros. If you're not familiar with Excel (or whatever you're planning on automating with VBA), do that before attempting VBA.
This VBA tutorial is highly recommended: Excel VBA For Beginners and Microsoft's Documentation.

Changing the data source of pivot table in VBA

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)

Resources