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
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:
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?
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:
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.
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.
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.
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.
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.
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...
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?
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..
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.
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:....................
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:
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.
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?
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)
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.
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'.
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?
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 ....
I am trying to insert a Pivot table with dynamic Name Ranges. It needs to start from Cell B1 as Column A has hidden formulas in them. I created an Dynamic Name range and tried to insert a pivot table. Excel then throws out a error stating "Data source reference is not valid". I tried re-saving the document but still no luck.
I am having a hard time creating my ultimate gradebook. Right now, I am able to hide a SPECIFIC table on a SPECIFIC worksheet using the following code on a macro button:
VB : Sub HideRow()Range("Table2[#All]").EntireRow.Hidden = True End Sub
The problem is that this sheet will be a template and as a new user inserts a new sheet, I would like to copy and paste this template to each new sheet. Since the Table values change with each new sheet, code wont work on the new tables. How I can name each new sheets table "Class Data", and the macro button to hide will work on each respective sheet?
On another sheet I would like to create a list of the countries.
However the list should be dynamic: I want that the last country in the list is UK. It should stop, when it sees the first element of the list for a second time.
The reason: In some years the list might change, countries will be added or similiar. For example: there will be a new entry called "EA19" => the list will have 1 additional entry.
How would I select a dynamic range in VBA without using name a range in Excel. I have searched for possible answers, however they use xldown, or xlup which works great for non-empty cells. My problem need to select the area where there are empty cells. Here is a snap shot of the data looks like:
Trade Date A B C D E 2008-Feb-11 450,432 2008-Feb-13 2008-Feb-15
The cell with number is where I got the formulas. Now i wish to fill that formula with the rest of the area. However, the problem is the number of rows and number of columns may change in the future. So I need to select those empty areas in a dynamic way.
- 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.
I have a pivot table summarizing a lot of weight data on the product that we make. I have the actual weight and the specification weight, and a calculated field for the % over or under weight.
What I want is also a pivot column to show the range of weights for each product code. I have added a column (calculated) giving the weight difference (in gm) but when I collapse to summarise for each product it gives the sum of the differences. I think that the best thing may be to use an array formula on the source data table in order to give the range but I have not tried that yet.
I have a data management issue that I have been able to resolve using SUMIFs and a custom table, but not in pivot form. Since the data source is a SQL database, I would prefer to resolve the issue in pivot form so that future values chart correctly. The data is formatted as so:
Job Day Start Day End Size Project
1 1/1/2014 1/10/2014 10 A
[Code] ......
From that data I want to see the total size of projects active at the start of the week for the past year. This would essentially mean summing the size of the projects if the week start date lies between the day start and end. This is what I ended up with:
Year Month Week Weekday Start Active Size
2014 1 1 1/1/14 10
[Code] .....
This is the associated pivot chart:
This would be "OK" except that I would also like to see the size breakdown by project, like this:
This is where I would need the data to be handled purely in a pivot so that when a new project is added, the pivot table will automatically make the summing column for it rather than my manual creation of columns for the data.
I have uploaded a link to a work book with the examples of the data and how I made the charts above. You can see that to make the second chart I had to manually create the columns for each project:
Download PivotExample.xlsx from Sendspace.com - send big files the easy way.
My Userform with combobox entries for product checks against the rowsource and if not on the list, is added to the list. the list is a named range in a Table that is used in a data model.
No matter which way I try I am regularly getting a corruption in the table that is home to the named range which is the rowsource... after one or two entries from the userform.
The rowsource is not bound to the worksheet, it is populated at userform_initialize procedure. (There are 4 combobox drawing from same rouwsource hence the loop through to check each)
debug points to the line at which conbobox value is being entered into the rowsource, though not always - it sometimes just crashes the whole file and everything needs restarting, upon which the table is fine and entry is evident.
I have tried resize, addrow to bottom of table variations and all result in the same core problem of a table corruption that crashes the file.