I'm creating a pivot table based on a section of data that will continually be of variable size. I'm trying to think of a way to command VBA to create a pivot table without giving an absolute reference to the table's source data. I can automatically select all of the data regardless of size, so I'm trying to see if I can command Excel to create a pivot table based on "Selection" instead of an absolute reference, in much the same way I might use Selection.Name instead of specifically defining a name's parameters. This is the text I currently have in VBA for the pivot table.
I have the following code to update a pivot table:
Code: Dim pt As PivotTable Application.EnableCancelKey = xlDisabled For Each pt In ActiveWorkbook.Worksheets("sheet1").PivotTables pt.ChangePivotCache ActiveWorkbook.PivotCaches.Create _ (SourceType:=xlDatabase, SourceData:="source!R4C1:R33443C55" _ , Version:=xlPivotTableVersion10)
the R33443 term is what will be changing, the columns and the starting row should stay the same. is there a way to instead of using R33443, to enable the range to be changed based on a cell value?
I seem to have a small problem with a Pivot Table on a file that we get weekly. I've built a macro to run across the file to format it and refresh. The problem is, sometimes it fails because the Pivot Table is listed as "PivotTable1" and sometimes it comes through as "PivotTable2".
I'd like to amend it so that regardless of it's name, it can be renamed to "MainPivot" or something similar.
- 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 am running into an error when creating a macro to make a pivot table and sum certain columns. I am fairly certain this is due to the name changing to PivotTable2, 3, 4, etc. each time. Is there a way to make the name stagnent so when a table is created in the macro it doesn't error out the formulas? I have an example below.
Using Pivot Table, I added a field to the "Values" field in order to give me a sum of the numbers. The title automatically changes to "Total", I am needing it to show "Total Invoice to OOM Delta". Is there a way to do this? I tried the Active Field option, but that's not working for some reason.
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.
I often use the same file/pivot table for both month and weekly reporting. In my source data my field headers show 1,2,3,4..etc. This way I can use for month or weekly. But I often change the "Custom" name on the Field Value Settings to something more descriptive like "Jan" or "Week1"
The problem is that each time I update the the "Custom" name the Pivot Table auto refreshes and it takes forever to re-label all the columns.
Is there a way to suppress this refresh when updating the Custom Field Name?
I have a set of four pivot tables on a sheet that I need to programmatically change a Report Filter (Page Field) so I can create sets of reports in an automated fashion. This will be the first step in that process. The change will involve choosing > 1 Role each time the code loops through based on Named Ranges I've defined that are associated with that Role.
My code thus far:
Code: Sub TestCode() Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem
emm_dc_gsr is one of many Named Ranges that will contain a variable number of elements. Just using the one right now to see if I can get the code to work, I'll eventually make another Named Range/Array of all them so I can loop through each Report ("ReportPick").
I want the Report Filter to consult that Named Range for its values and apply those values to PivotField "Role" that is used as a Report Filter.
When running this code above, I get a "Role" Field that says "All" but no values (the table is completely blank), with no evidence as to why it'd be blank (all filters in every Report, Column and Row are working normally and are filled in). When I choose a value manually after the code is run, the pivot table values populate. Do I need to somehow index the Named Range in that loop? I'm just confused about this step right here:
For Each pi In pf.PivotItems If pi.Value = RolePick Then pi.Visible = True Else: pi.Value = False
When I've run other versions of the code, I've gotten an array version of it to "work" using LBound and UBound, but it never chooses the right two values even though those are verified as stored in the array via a pass-through. It chooses the first few values in the Report Filter.
Here's the corresponding code for that:
For i = LBound(myArray) To UBound(myArray) pf.PivotItems(i).Name = myArray(i, 1).Value pf.PivotItems(i).Visible = True Next
I do not care if I use an array or a Named Range. I just want something that is simple and works. Passing the values directly from the named range seems easiest to my brain, but I'm open to anything and I'm clearly missing something (probably silly).
I also have no idea why " .AutoSort xlManual, .SourceName, .EnableMultiplePageItems" is necessary though every piece of sample code I've seen seems to have some variation of it.
I created a nice excel file with some cohort analysis regarding the number of months customers of different cohorts stay with a company. Basically I do a little manipulation on the raw sign-up data sheet and then run a pivot on it.
I want to see the cohorts in two ways: 1. number of customers. 2. $ from customers.
I have the first 1 and I want to get the second one without going through the same procedure again (i.e. manipulating the raw data). In order to get the $ terms, all I need is to multiply a $ column in each row in the columns that indicate the number of months that passed since a customer joined (see the attached example file please). When I try to do it with calculated fields in the pivot table, Excel multiplies the total number of customers with total $ from them all put together, which is of course wrong.
Any way to achieve what I want without having to created another data sheet just for $ terms?
I believe the attached excel file: dummy_for_cohort.xlsx
I have enable Refresh on Open for my excel pivot table, but user need to click "Enable Automatic Refresh" , only solution i came across is to change the registry setting. Which i dont have access to edit registry(admin disable the access).
Alternate solution i try to use Access macro to automate the process and use Outputto save it as a excel file A. Then use excel file B to update pivot table from excel file A.(as excel A data is always latest) The problem is i will get "....A file name already exist...do you want to overwrite.." prompt. Which defeat the automate process.
Any other solution to enable the automatic refresh on open the excel workbook?
Or Access can overwrite the exist file or save it as another file name with timestamp ?
I manage a team that quote for business. They are targetted on number of quotes per month but then also wins per month, however a win may come a number of months after the original quote was generated.
They work off a spreadsheet where they log:
Quote date (And month) Quote Value ... customer info etc
I started writing my pivot using the Quote month as the main reference point, IE Quote Month in the Row, and then put all the data in the central drop data section... However, there are two immediate problems with this:
They are targetted on quotes generated per month, some business won has come from last year, which they are lifting from the old spreadsheet and puttin in my new one... meaning that quotes they generated in Oct 2012 are now showing up as quotes for October this year.
If the wins span a number of months they are showing in January (if quoted in January) and not in March (when actually won)
Is there a better way of writing my pivot table??? There must be... ideally what I would like is half the table referencing the Quote date and half referencing the order date... but I don't know how to do this? I could probably do this with pages but I would like to show all on one sheet...
I was wondering if there is any way possible to link your pivot table filters to filter the data the same way in the table that it comes from? So if i had date as one of my headers and i filtered the date to a specfifc date, is there a way to also filter the date in the data source sheet?
I am creating, essentially, a product order form (actually a shopping list creator for my wife). Containing 'Quantity', 'Product Name' and 'Price'. When I enter the product name via a drop-down list, the price is displayed using vlookup.... no problem so far.
My problem is... or should I say, my desire is, that when the vlookup price is displayed, if I (my spouse) know the current price to be different from the one retrieved from the lookup table, I would like to post the new price and modify the data in the lookup table so that any future requests for that item will reflect the new price.
I would like to change the data layout from the "Original Table" to the "Final Table" as in attached file. Belinda_June-25-07.xls. How do I use VBA to do the change? In my original table, I may have several hundred rows and more than 36 columns for the time periods.
why is pivot table changing numbers to dates. It was fine all along, numbers retained the fromat of source data and now, all numbers in field columns are turning into dates. is there a setting I can change to prevent excel from reformatting numbers to dates?
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.
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"
I have a excel based timesheet that looks at an external table named "Station Master" to populate columns from a vlookup. I have recently linked the Station Master to a database to populate it. From the database we may change status so that the project does not show up in the station master anymore to make sure complete projects are not getting hours charged anymore. Now if a project that was on the master goes away previous timesheets lose the correct description because it is not on the station master anymore.
My question is there anyway to make the previous data lock so the data that is in the cells won't change when the station master changes.
A little more info... the time sheets are by quarter so 12 weeks are in the same workbook as individual worksheets. All of those worksheets vlookup to a worksheet called "projects" inside the workbook. Then that worksheet references the external Station Master workbook.
I have data that develops 3 to 4 pivot table each day. I would like to know if there is a way to change the date on one of the pivot table and have the other pivot tables date change to match with the first pivot table. At this time I am going to all 3 or 4 pivot table to select the correct date. The date is in the page position of the pivot table. I have attached a small sample of the data and the pivot tables.
I have created a pivot table that is connected to an input sheet with data. The input sheet retrieves data automatically from a external source through an add-in to Excel. When updating data the fields expands, but only for the items which have been changed. I want the table to be updated automatically, but not the fields expand automatically. Is there any pivot options to prevent this problem?
It should be mentioned that the pivot table is not directly connected to the input sheet (which is updated from the external source), but from a "help-sheet" reflecting the input sheet with some additional columns. I use conditional formatting and name range in the pivot.
vba in excel 2013 pivot table that updates from an online CRM rows are a to h and it can be any number of rows. What I am trying to do is track progress. In column f values indicate probability for success 10 25 45 90, which can go up or down. The pivot table is refreshed to get the latest values from CRM. the update is handled by a connection to the crm not in the vba.
So far I been researching methods to conditionally format values that went up, down or remained the same since the last refresh with up down and across arrows. I have managed to piece together what I think should work but alas it is not. So I have come to you internet.
My code first clears any formatting and goes down the column avoiding null or empty cells, comparing the values in column f to values in column j. I have 3 conditions greater than, less than or equal to, and would like add an icon for each based on the result of the comparison.
Finally when it finishes the column the code copies the current values in the pivot table column f to column j outside the pivot table which i hope to be able to hide once the cf works. The code is below
is there any way to NOT Displaying Items with No Data when filtering data in my pivot table?
For instance, I have 2 report filters: Category and Subcategory, when I select a category in the first filter I want to see only the options of subcategories with data in the second filter, I mean display only the subcategories of the Category previously filter.
Same scenario I have with a report with Directors and Organizations, when I filter one Director it would be nice to see only the organizations of this director and not all options on the data.
I'm using Excel for bookkeeping and balancing a budget. I've created one sheet for all my raw data and the other is to summarize the data using a pivot table. On the raw data sheet I have labeled my columns for the pivot table. I was hoping that in the pivot table I can select a year and have all the months for that year and data of that year be available, but not other years. I was also trying to have only the month selected of a year selected and that data be available. I also wanted to show an accounting of money spent by item.
Instead, I have a pivot table that is confusing and very unattractive. The example of this will show my limited knowledge in pivot tables. I'm hoping some of you more affluent "guru" members may be able to help me get something usable and presentable.
I tried creating a dynamic named range for the pivot table "BookKeeping" and a dynamic named range for the money out and money in "Accounting", but I'm not sure if I did that right. I did this because more columns will be added over time. This is the reason I'm asking the above two paragraphs.
Should I be using filters some how?
The Summary Sheet also has the balance of available funds that I'm somehow looking to include in this pivot table. Can the pivot table keep a running balance?
Data Analysis . I have 7 tables gathered in one spreadsheet but in seperate sheets. Tables have the same columns but different data baceause they come from different locations. Now I would like to create pivot table to combine data from all 7 tables. I read a little and I got to know that relationships is needed between the tables but I can't create it because I don't have unique data in the table. Usually tables consist repeating names, locations, some numerical data.
For example every table consists worker's name. I create pivot table from one of 7th starting from worker's name in row field and put some data in value field. Then I add another workers from another table. I can do it but when I put in row field I have workers from second table under those from first one. And of course data are badly calculated. I would like to have all workers in row field with proper data. It means one column with all workers from all 7 tables an then some their data
I know I can copy all of them into one big table and then create pivot table but this is solution what I wanted avoid. I know it will work but these data can change from time to time and it will be very hard to maintain spreadsheet. When data will change I will have to copy manually .Is there any solution to create such a pivot table from multiple tables sources but with the same column structures?
I've been asked to work out a way to easily present summarized data which, when so desired, should be able to go into deeper detail. The only way I know how to do this is via Pivot Table. The thing is, that simply adding the numbers doesn't make sense at all. The reason is that I'm working in share of market per country and simply averaging these shares doesn't make sense due to different market sizes in terms of absolute volumes. Hence different weights need to be given to each share. Allow me to illustrate: I'm interested in Belgium, the Netherlands & Luxembourg and their combined area, the BeNeLux. Each country sells products A - C. Adding the numbers per country is fine as that total amounts to the total company share for that country, but for the area it doesn't. So what I want to do is show the data as follows (see also attached screenshot):
BeNeLux --------> Belgium -----------------> Product A -----------------> Product B -----------------> Product C --------> Netherlands --------> Luxembourg
I want each click to go into further detail, but initially it would show only BeNeLux - only after clicking it would show each country separately and if needed, the products after another click. I have all the numbers such as share for the area but I can't seem to get it to show the right way.