Macro For Dynamic Pivot Table

Jun 23, 2014

I am trying to make a dynamic pivot table using VBA. Unfortunately, Im not very good.I have a set of data with variable number of rows and variable number of columns and I need to make a pivot table. Need to select this data from sheet - Master, where the first data entry starts in cell A1. of the data in the sheet, i only need the name and age title In the pivot table fields -

ROWS needs to contain - name
COLUMN needs to contain - Age
Values need to contain - count of Age

After this is done, since the data will be dynamic, the pivot table will also be dynamic. i need to copy the pivot table data and paste it in another sheet so that I can do some filtering. The filtering part I think i can do my self.

View 3 Replies


ADVERTISEMENT

Dynamic Refresh Pivot Table Pagefields With Macro VBA

Jul 8, 2006

A simple example of the problem: Imagine a pivot table has two pagefields at the top. The first list the gender ("boy" or "girl"). The second one below it lists people's names. How can it be programmed so that when the first (gender) filter is selected to "boy", pagefield 2 (the names) will only display the names of boys. So I would like the pagefield to work like regular multiple filters would. (And not list every possible item for all)

View 2 Replies View Related

Set Pivot Table Dynamic Source Range Macro Code

Apr 9, 2008

Ultimate goal is to automatically update the source data for 4 pivot tables that are on 1 worksheet. The data for those 4 pivot tables are on 4 different worksheets w/in the same workbook. Consolidating into one dataset is not an option.

I'm familiar with a dynamic named range, but the 4 worksheets that contain the data are replaced daily via automated Access output which creates an error.

I know how to do this adhoc by matching the pivot table names with their respective worksheets, but there are many other documents with similar layouts where this would beneficial.

Below is an example of how I currently update 3 pivots on separate worksheets w/ the same data range which is w/in the same workbook. My proposed changes are below the current. Any ideas on how to return the workbook name as a string...Or am I going about this the completely wrong way...

View 8 Replies View Related

Macro Code Create Pivot Table Based On Dynamic Source Data

Nov 28, 2006

The "Sum" sheet can change its number of rows. The pivot table is based on it. I'm having trouble with the SourceData portion of the code in my macro ....

View 9 Replies View Related

Dynamic Pivot Table ....

Aug 28, 2008

I have a spreadsheet the includes data validation, auto fill fields using formulas and conditional formatting all over the place. The user will be adding rows of data whenever applicable, so I want to create a dynamic pivot table that will update automatically. I think I've done it properly, Insert - Name - Define. In the Refers To field, I've added:-

=OFFSET(Sheet1!$A$10,0,0,COUNTA(Sheet1!$A:$A),12)

I've then based the Pivot Table on the defined name. For some reason, when I add a new row of data, the pivot table doesn't update, I have to do it manually. When I go back into Sheet1 and click in the Refers To field, there is an extra "blank" row showing as included in the data range (screen print attached) Is my OFFSET wrong, or does it have anything to do with the fact each row (down to line 300) contains formulas and #N/A's?

View 10 Replies View Related

Pivot Table Dynamic Grouping

Sep 15, 2014

I have a table with outstanding days for Funds owed by multiple accounts which dynamically changes everyday I am looking to group this table by >5days, 6 to 14 days , 16 to 40 days ,>40 to 90days and >90days consistently even though the table will change dynamically every day..

View 4 Replies View Related

Dynamic Pivot Table Range

Nov 8, 2011

I've a macro that generates a pivot table from another excel workbook, however i need the range to be dynamic as the excel workbook im generating the pivot table from changes in number of rows on a weekly basis. Here is the existing coding:

Code:
Sheets("QA").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"QA!R1C1:R22580C12", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="Pivot!R3C1", TableName:="PivotTable2" _
, DefaultVersion:=xlPivotTableVersion10

how to make the SourceData dynamic

View 1 Replies View Related

Pivot Table With Dynamic Range?

Mar 27, 2013

I have a sheet in my workbook called Results. This sheet contains a list of a fixed set of columns (A - N) but with a variable number of rows.

I am trying to create a macro to create a pivot table from this data, which automatically selects all the rows in the Results sheet to form the data set.

I've had a look at some of the other threads on this topic, but just can't get this working.

I have the following code that I have pieced together from other threads - you will see I am trying to set "PivotRange" as the data set and include this as the data source in the pivot. I get a subcript out of range error when I run this.

Dim PivotRange As Range
PivotRange = Range(Worksheets(Results).Cells(1, 1), Cells(lastRow, lastColumn))
Sheets.Add

[Code].....

View 1 Replies View Related

Pivot Table - Using A Dynamic Range

Jan 6, 2009

Because my pivot table is used by several users the data source changes often. In response, I created and applied a dynamic range using the offset formula. While the pivot talbe grabs the correct # of records, it inserts a blank column and row. There are NOT any blank cells in the data source range, as reflected by pivot table counts for the Blank column and Row. Any idea why Blank is showing up in my pivot table and how I can correct while maintaining the dynamic range?

View 9 Replies View Related

Dynamic Rows For Pivot Table

Nov 16, 2006

I wish to create a Pivot Table. It is based on source data with fixed columns (A to W) and dynamic rows. The following is my

Dim WS As Worksheet
Dim DataRange As Range

Set WS = ThisWorkbook.Worksheets("sheet1")
DataRange = Range("A1:W1", Selection.End(xlDown)).Select

ThisWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=WS.Range(DataRange)).CreatePivotTable _
tabledestination:=Sheets("sheet2").Range("A1"), tablename:="PivotTable1", defaultversion:=xlPivotTableVersion10

Dim PT As PivotTable
Set PT = ThisWorkbook.Worksheets("Sheet1").PivotTables("PivotTable1")
PT.PivotFields("Type of Work").Orientation = xlPageField
PT.PivotFields("Profit Center").Orientation = xlRowField
PT.PivotFields("B/(W) CTD Net Rev").Orientation = xlDataField

Because I'm going to use it in my work, it must be reusable. And every time I use it, the numbers of row are different. Therefore, I made the source data into a dynamic range. The range changes when rows change. However, problem always appears in the following line:....................

View 2 Replies View Related

Use Dynamic Range In Pivot Table

Dec 21, 2007

Im trying for the first time to use a dynamic range as the 'source' for a pivot table. The pivot table and the source data are in two different tabs. The source data is on tab Log! and i have used Daves formula (i hope correctly) to define the dynamic range. The range starts at Column B and is 22 columns wide:

Refers to:=OFFSET(Log!$B$1,0,0,MATCH(""*"",Log!$B:$B,-1),22)

I have named this dynamic range DMR. I have a pivot table on another tab. When i try to use DMR as the source (Log!DMR), it gives me an error "Reference is Not Valid". I must have the syntax wrong somewhere.

View 3 Replies View Related

How To Create Dynamic Pivot Table Title

Jun 7, 2014

I have a pivot table without report filter and I set insert page break after one of my selected row labels.

I also would like when I print, these row Labels become the title of these pages at the same time.

Actual File : Untitled.png

However I would like when I click on print or save as pdf will print all pages as one file and each Center that I have set page break for, in separate page and add that specific center as its title:

Attachments for more details:

test_Page_1.jpg
test_Page_2.jpg
test_Page_3.jpg
test_Page_4.jpg

View 4 Replies View Related

VBA To Find And Select Last Row In Dynamic Pivot Table?

Jan 31, 2014

I am having issues with a VBA script. The Spreadsheet is linked to a SQL DB and updated with data from scripts that are executing throughout the day. This is then fed to a dashboard. We have a Baseline that shows in the Date column as 0/0 and 1/1. I need a way to ensure that the 1/1 is always in the last row of the chart so the baseline shows across the entire range of dates. The current method is to declare a variable and add 1 to it whenever we iterate through the sort for the other dates. However everyday the 1/1 baseline column ends up further to the beginning until it is next to the 0/0 in position 2.

So I am trying to find a way to have the macros find the last row of the Date field and then set the position to be equal to the last row.

View 4 Replies View Related

Pivot Table - Dynamic Source Data

Sep 26, 2011

I am using pivot tables/charts for drilldown reporting. After running a complex macro to consolidate multiple reports into one range, I need to generate pivot tables and charts.

These reports will change month to month in the number of entries they have (template will be identical), and therefore my data source range for the pivot table is bound to change. Therefore my question is, how to develop a macro that will dynamically change the source data range to the amount of rows?

View 5 Replies View Related

Excel 2003 :: Dynamic Range For Pivot Table

Jan 21, 2013

How do I create a Named Range that is dynamic (I think using the OFFSET function) that automatically expands and contracts as the rows and columns of my data changes?

Next step, I then want to use that Named Range as the source of the data for a PivotTable.

Yes, I know starting in Excel 2007 you can use Tables and don't need to create a dynamic named range. That is not an option at this time.

View 1 Replies View Related

Pivot Table Dynamic Range, Last Used Cell Not Same Column

Oct 26, 2009

I've got two pivot table reports working off one dataset.

I've named the range Recharge with the formula as below..

=OFFSET('Recharge'!$A$1,0,0,COUNTA('ABC Recharge'!$A:$A),16)

But this uses column A as the longest column... but sometimes it will be column I - how can the formula be adapted ? or can it be ? i've been looking at the Max function and trying to incorporate that but my limited brainpower has gone to mush.

View 9 Replies View Related

Dynamic Formula To Keep Column Of Data Aligned With Pivot Table?

Feb 23, 2014

In this file Vehicle Fuel Tracking.xlsm I have a pivot table set up to filter my data. Next to the pivot table I have a column that Totals the Mileage based on the MAX and MIN of each group. I am looking for a dynamic formula to keep the totals alligned if data is added or deleted from the pivot table.

I would also be open to changing the data table to accomodate this request if needed.

View 12 Replies View Related

Dynamic Range For Pivot Table :: Error : Reference Not Valid

Apr 26, 2009

I am trying to create a pivot table on a new sheet names as 4x4

I am getting following error:

Error : 1004
Reference Not Valid

I am not sure where is the problem. I have generated this code by using macro recorder and just changed the source and destination of the pivot generation code.

View 9 Replies View Related

Adding Columns With Manual Calculations To Dynamic Pivot Table

May 8, 2013

I have a problem as I need to present data with different data sources. I'd like the calculations to be as "automatic" as possible. The data consists of countries and regions and their sales pipe. The pivot table doesn't give me all the data that I need to present so I need to add extra columns with calculations and data from other data sources.

The problem I meet is that the 'total row' within each group needs to be reflected in my columns as well (F:G) It works as long as the data I've imported has the same amount of States within each group of Contry but if the number of states differs with the newly imported data - my "manual" columns are wrong.

(A;B;C;D;E;F;G;H)
Country;State; Red; Amber; Green; Quota; Total PV; Coverage;

I've created a Pivot table on the first 5 columns [Country; ...; Risk] (A:E)

The following columns are manually entered based on the pivot (F:H)

Quota (data source from another sheet)
Total PV (a sum of Red; Amber; Green in the Pivot)
Coverage (returns % of TotalPV/Quota)

For each group Quota and Total PV needs to summarize the above data within the group. I've 'hard coded it' today (SUM(F3:F5)) - F3:F5 can as well be F3:F8 or F3:F4 depending on the imported data. I have 8 different Countries (groups) with different amounts of States and 3 different sheets for each Region of countries so I need this summary to be automatic based on what group (Country) it belongs to. How can I make the calculation different so that it's dynamic as well as the Pivot table? Today it's not dynamic and it needs my 'hands on'.

Quota =IF(ISNUMBER(SEARCH("total";A6)); SUM(F3:F5); IF(ISNA(VLOOKUP(B6;Quota!B:F;3; FALSE));" ";
IF(VLOOKUP(B6;Quota!B:F;3; FALSE)=0; " ";(VLOOKUP(B6;Quota!B:F;3; FALSE))))).

View 1 Replies View Related

Pivot Table With Dynamic, Updatable Chart, But Not A Pivot Chart!

Dec 19, 2008

My boss wants me to design a dynamic, updatable chart in Excel 2003. I initially made a Pivot Chart based on a Pivot Table which worked perfectly, but it doesn't look professional enough when printed (or viewed) and she wants me to approach it a different way.

So, I created a graph based on the data in a Pivot Table, and used dynamic ranges as the source for the graph series so that the chart updates when the criteria fields are changed for the Pivot Table. I then added two combo boxes (ie data validation lists) to the Chart sheet, and wrote VBA code so that whenever the combo box values are changed, the Criteria fields for the Pivot Table on the 2nd sheet are updated accordingly, and this in turn causes the graph to be updated as well.

This solution also worked perfectly, but now I've been told to create the graph without macros.

Does anyone have any suggestions? The requirements/details are as follows:

1. The Pivot Table is on sheet "PIVOT", and the graph is on sheet "GRAPH"
2. The Pivot Table has two criteria - School Name and Year Level
3. On sheet "GRAPH" there are two data-validated fields, School and Year, which only allow the selection of valid Schools and Year Levels

Is there any way to make the Pivot Table update when values are changed in the fields on the CHART sheet so that the chart also updates, but without using code nor a Pivot Chart?

View 9 Replies View Related

Dynamic Range For Pivot Table :: Error : Range Is Invalid

Oct 28, 2009

I am trying to get to grips with the dynamic ranges for pivot tables. I have named a range data and in the refers to section put:

=OFFSET(Sheet2!A1,0,0,COUNTA(Sheet2!A:A),COUNTA(Sheet2!1:1))

I was hoping that then when i go to data > Pivot table and it asks for the range i could put =Data but it tells me that the range is invalid. I have attached a copy at the bottom.

View 3 Replies View Related

Macro To Sort Dynamic List Into Table

Nov 16, 2008

I have a list of letting agents that I need to sort into a table to import into Access. The list is dynamic in that not all the fields are present for every record. I will have over 4000 records to sort out, so I would really like to automate this. If possible the macro should read rows from the data worksheet and write to columns and rows on the Table worksheet. I have attached a small example of the data and output required. To make it a little more challenging the column header name is part of the data and will need stripping out as well.

View 3 Replies View Related

Excel 2010 :: Pivot Table Reference Is Not Valid When Moving Data And Pivot Table Together?

Mar 19, 2013

On a worksheet, I created:

- a list of data
- a pivottable based on these data

When moving this worksheet this worksheet to another workbook, the pivot table can't refresh anymore. This throws an error message "Reference is not valid". To work around this problem I need to adapt the datasource. The same occurs if the list and the pivot table are on separate sheet, with the added strange behaviour that, when data an PT are split, it is not possible to move both sheet together.

This would not be a big issue if my problem had to be solved manually. The real problem is that I need to move the sheets from a C# program.

View 3 Replies View Related

Split Up Huge Macro Using Call Macro But Pivot Table Code Errors Out?

Jul 10, 2012

I'm using a CALL Macro to split up a HUGE macro into different pieces:

Code:
Sub RSLDASHBOARDV2()
'Macro recorded 12/14/2010 by Ryan R. Koleno, Pharm.D.
'Last Updated 7/10/12 by Ryan R. Koleno, Pharm.D.
'Do Not Modify Code Unless Given Proper Privileges to do so.
Dim APPSPD As Worksheet
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual

[code]...

The first few macros dealing with page setup and what not work fine but when it hits the Pivot table code for the STATSPIVOT macro it errors out stating: "Run-time error '1004': Unable to get the PivotItems property of PivotField class' at this point in the code:

Code:
objField2.PivotItems( _
"TRC").Position = 1
objField.PivotItems( _
"MEDCO MAIL OR AOB").Position = 2

When this macro is not split up it worked fine as written. Am I overlooking something in the Call Macro's code or is there a variable I'm not aware of. I have included the Pivot Table code that errors out as well.

Code:
Sub STATSPIVOT()
'STATS PAGE BASED ON STATS DATA TAB
Sheets("STATS DATA").Select
Dim objTable As PivotTable, objField As PivotField
ActiveWorkbook.Sheets("STATS DATA").Select
Range("A1").Select

[code]...

View 4 Replies View Related

Create Pivot Table: Cannot Open Pivot Table Source File

Jan 4, 2010

I'm trying to write a macro that will create a pivot table, and am getting an Error code 1004: Cannot Open Pivot Table Source File "Sheetname". My code is below. I've tried to note what each section does, and it all seems to work well except for the Pivot Table creation.

View 14 Replies View Related

VBA - Adjust Pivot Table Included Fields To Match Another Pivot Table

Mar 14, 2013

I have a worksheet with two pivot tables, one of which is visible to the user. Ideally, the user should be able to change the "Row Label" field settings of the visible pivot table and then press an "update button" that then adds the same field to the second pivot table.

Ideally, the ordering of the fields should also be made similar between the two tables, though this is of less priority.

I imagine it would be something in the style of:

"If number of Pivot1 active row label fields = X then
Pivot 2.AddRowLabelField = Pivot1.RowLabelField(X)
end if"

View 1 Replies View Related

Pivot Table Query: Make A Pivot Table To Summarise The Data

Jan 22, 2007

attached is a spreadsheet 6 people in my area use daily(ive copied and pasted the sheet in question to a new worksheet, as the file was too big). Ive been trying for about 3 days now to make a pivot table to summarise this data.

View 6 Replies View Related

Pivot Table Macro....

Jul 25, 2009

I have a pivot table macro below. It works great:

View 3 Replies View Related

Macro To Create Pivot Table?

Jun 3, 2014

Can record the all those actions which we need to do on a regular basis. In my work i have to create the pivot table to a data which gets changed every day but the data sequence remains the same.

I have tried to record the macro for the pivot table but when i tried to run the macro again then the below error message comes.

"run time error 5" "Invalid procedure call or argument" when i click on debug then the below macro program is highlighted in yellow color.

View 1 Replies View Related

How To Make Pivot Table Using VBA Macro

Aug 19, 2012

i want to make the pivot table using vba macro. the sample workbook looks likes this [URL]...

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved