I have a spreadsheet with a pivot table that is based on a table within an SQL Server database. Every month a stored procedure is run creating a new table. Using the pivot table wizard I can modify the underlying query to access the new table. The pivot table functions properly with the new data.
I also have a macro that I created that will cycle through all the combinations of page field pivot item values, setting the page field currentpage, do some calculations, and save the results.
This is bombing because it seems that some old date values from the previous month's table are still in the pivot items and when my macro attempts to set the page field's currentpage to one of these values it generates Run-time error '1004' Unable to set the _Default property of the PivotItem class.
I have tried putting a pivotcache.refresh in but that doesn't seem to help.
I'm trying to create code where a user can input criteria into a cell then run a macro. The macro would then use that criteria to filter the pivot table. I have attached an example. The first portion, using date to filter the current page - pivot item is working. I need to creating the code to use the "supplier" to filter the pivot items on the row. As a note, both the Date and Supplier cells are named references.
I have created quite a nice little macro that; drills through a lot of key figures, updates a pivot chart and copies the chart to powerpoint.
However it crashes on one particular data set every time with this error: Run-time error '1004': Unable to set the _Default property of the pivot item class
The code where the debugger stops is the last line below here.
I can manually change the pivot chart to the keyfigure it crashes on and thereby workaround the problem in the macro. Also it works for more than 50 other keyfigures without problems.
I was wondering why a pivot table will allow you to tick and untick pivot items that are not visible?
My pivot tables have a lot of data and someone may wish to only see the pivot items that are shown in the pivot table in its currrent view. Is there a way in VB to achieve this?
In my attached example when you suntick the Media 'TV' then look in the 'Channels' drop down you can still see the tick boxes for TV channels 'ITV' and 'TV_BBC1' (I know why they are still ticked, I'd just like them not to be visible).
I'm not grasping the Pivot Table correctly. I've written code to create a sum of values based on a worksheet. Specifically:LocationIDDeptSum of Hours Worked. Location, ID and Dept are rows. This effectively provides the aggregate values that I need based on the row groupings.Here's where this is falling apart. I need to create a new worksheet based on these values. I assumed the three row values - Location, ID and dept - would be in a hierarchy. It's possible they are, I just can't figure out the object model.
When I loop through the PivotItems collection of the PivotFields("Location"), I get what I need. However, I'm unable to determine how to loop through the child values (just for that location). PivotFields("ID") returns all IDs. I can't figure out how to return only the child entries for each pivot item. GetPivotData hasn't been very useful for this. As far as I can tell, GetPivotData, while its return type is listed as Range, throws an error when more than one cell is returned. Worst case, I suppose I can just parse the data in the DataBodyRange of the pivot table - maybe not, I haven't tried that. I'm hoping there's a way to iterate through these collections, but based on what I've seen from Google searches, there may not be. Does my pivot table need to be rearranged? I suppose I could also just dump this data into a data table
I'd like to update some of the hardcoded numbers to functions that would pull from lookup tables. However, when I enter this in A1,
="Blah, blah "&B1&"."
In a "fresh" spreadsheet I get "Blah, blah 2009." , in cell A1 where B1 has 2009 typed in. In a "stale" spreadsheet I get "#VALUE!" in cell A1 (with 2009 typed in B1).
I've tried right clicking--> format cells and then changing to a variety of formats w/no luck at all. The only thing that works is to create a new sheet in the workbook and reformat the table and cells by hand. Clearly this is an ineffective workaround.
So, exactly what is the property that I need to reset in the "stale" worksheets that will allow, ="Blah, blah "&B1&"." to be read properly?
I had a question regarding pivot charts. Someone sent me an excel spreadsheet and i wanted to copy the pivot chart exactly but change the values. I just get the error that says "you cannot edit data in calculated fields" etc. I really just want to use the exact same set up but change a few numbers around.
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'm trying to insert a calculated row in a pivot table. I keep getting the error message 'Pivot table items can only refer to items in the same field as the calculated item'
Below is the format of my data:
Region(All) Sub Division(All) Sub Cluster(All) Cluster(All) A/C Level 3(All) A/C Level 1(All) A/C Level 4(All) A/C Level 5(All) Division(All)
Values A/C Level 2Sum of FY11Sum of FY12Sum of FY13 Net Revenues 100 200 300 Op Exp 50 40 30 Calculated Field50 160 270
Attached is a worksheet example, of my beauty salon with 5 therapists.
The input sheet - is the shhet into which I input data on a daily basis.
Weekly inc - This sheet shows the total that each therapist made in apivot table based on the input. The week numbers are 1 to 52 (or 53) depending on each financial year (07/08, 08/09 etc).
What I want to do is either have another pivot table or to add an calculated item to the weekly inc pivot table showing me how much commission each therapist took each week? This is to be done automatically by excel.
This commission is calcluated by using the target comm figures - E.G. Leanne's target is £480 - so she has to earn £480 a week before getting a commission. So if in a week she earns £500 - she will get a commission on £20 (£500 - £480). The commission is 10%, so she will earn £2 that week.
I want to calculate the difference between Budget and Forecast, in € and %. I was trying to use a calculated Item but whenever I place the cursor on the Budget, Forecast or Category cells and try "Calculated Item", I get an error message saying that the Item cannot be modified..
I have cut down my problem to its simplest form - in the real world my spreadsheet is significantly more complex but the attached spreadsheet demonstrates it nicely!
The data is straightforward. PT1 shows the data without a calculated item whilst PT2 is the same PT but with the addition of a calculated item for GP (i.e Sales - COS). Unfortunately adding this has resulting in the PT growing and adding "ilogical" combinations of data that didn't exist in the source data.
In my current project I have "cheated" by using a helper column and filtering on this using the Worksheet_PivotTableUpdate event to hide the unwanted rows but surely there must be a way of removing them "properly".
Another problem, and I guess this is just the way it is, is that my PT takes ages to calculate presumably becuase it is calculating this formula for every combination of values?
I have an issue with a calculated item in my pivot table, because in the totals and subtotal it shows the sum of the column but I want to show the formula that I've specified to the calculated item.
For example, in the attached file, I have in rows the field "name" that has four values (A,B,C,D), in columns the field "Groups" that has "G1" and "G2". I add in the rows the calculated item "G1/G2" that has the formula G1/G2. The problem is that in the total the column "G1/G2" doesn't show the division of the total of "G1" and "G2".
Layout: Rows: City, Restaurant, Cashflow Column: Date (Month/Year) DataField: $Amount
"City" might be 7 cities "Restaurant" may be 32 restaurants, some in some cities; but not other "CashFlow" can be either "Revenue" or "Expense"
The layout of the Pivot table is nice, only shows the Rows where a State, Restaurant, and CashFlow entry exists for at least one Date on that row. And there are no extraneous rows for combinations that don't exist.
Now.... the trouble...
I added a Calculated Item, "Profit" which = "Revenue" - "Expenses". Now, every possible combination of State and Restaurant appears in the pivot table displayed. Only the "Profit" (calculated item) is shown for the previously hidden rows; and of course it's "$0.00" since there are no "Revenue" or "Expense" entries.
How can I get the Pivot table to not display the results of a Calculated Item row, when there are no entries otherwise for that row combination?
Is there a way to condition the Calculated Item to not calculate if there are no data entries in the addends for a particular combination?
I'm trying to get the parent item name of a clicked cell (e.g. when I double click on field "Commessa 2" I'd like to get "Region 3" and pass it to another sheet)
Here is my code:
[Code] .....
When I run this code, I get the message "Unable to get the ParentItem property of the PivotItem class"
the attachment is a sample spreadsheet of what i am trying to do. I would like to create a pivot table so that for each site I can list all of the organic suites individually. Then show a count of only 1 for each site, even when there are several counts for each site. And then for this to be related to a cost of each of the suites so that I can get a total cost for each site.
eg:
site name
organic suites suite cost o1 x o2 y o3 z Total A etc
I've used this code prior and it worked fine in Excel 2007, now I'm having issues with it. Originally every Pivottable & Query pointed to a different CSV file. Now I have two pivottables built off a Excel worksheet that is built from a Query. This allows me to do some complex lookups that I couldn't do with just the Pivottable and MS Query alone.
Here's the code that's failing out: Any problems with it in Excel 2007?
Private Sub Update_All_Data_Click() Dim pvt As PivotTable Dim ws As Worksheet Dim qt As QueryTable
mytitle = "This will refresh all data for validation, are you sure?" Msg = "The Refresh process takes about 5 minutes, are you sure you want to continue?" Response = MsgBox(Msg, vbExclamation + vbYesNo, mytitle) Select Case Response Case Is = vbYes ' Do Nothing, continue with program Case Is = vbNo Worksheets("instructions").Range("a1").Select End End Select
For Each ws In ThisWorkbook.Worksheets For Each qt In ws.QueryTables qt.BackgroundQuery = True qt.Refresh Next qt Next ws
For Each ws In ActiveWorkbook.Worksheets For Each pvt In ws.PivotTables pvt.RefreshTable Next pvt Next ws
mytitle = "Confirmation of data refresh" Msg = "The data has been refreshed" Response = MsgBox(Msg, vbExclamation, mytitle)
I am having an issue with my macro code. Basically I am trying to filter a pivot table by selected criteria. The code seems to be correctly filtering the pivot table but the table appears with no data in it unless I manually refresh the table. This defeats the purpose of automating with a macro. I have attempted a "work around" of just refreshing the pivot table after the filtering is complete but that was unsuccessful. Here is the macro code:
Sub BigReportMacro()
Dim pt As PivotTable Dim pi As PivotItem Dim pf As PivotField Dim E
The spreadsheet I have designed retrieves stats and data from individual player pages and stores them in an excel workbook.
I have used 20 seperate web queries, to import the data for each of my players (from an online cricket simulation game). This works fine, but my problem is that I want to make it usable for other players.
Player pages are titled playerinfo.pl?playerid=1020, through to playerinfo.pl?playerid=1039.
Ideally Id like the user to enter his lowest playerid into a cell, and then create the web queries for that manager's players.
I'm not sure if this is a possible scenario, or if I need to use a repetition loop in VBA.
I have a single workbook with multiple worksheets. Each worksheet has a different pivot table displaying a different view of the data. Each pivot table uses the same source data at worksheet1.
Each week i add new data to the end of the source data, which means that I need change the source data reference separately in each pivot table to update each pivot table view to include the new data. This is laborious as there are quite a few pivot tables.
Was wondering if there is some way of changing the pivot table source data reference on all pivot tables at the same time.
I have an SQL Server that has a query (a view stored on the server) which takes roughly 10-20 seconds to execute. This execution time is the same in Excel 2007 if I import data to worksheet/pivottable. It is also the same in Excel 2003 while importing data into a worksheet. It returns about 350 rows.
However, if I try to make a pivot table in 2003 based on this query, it is much slower. I can set it up fine, but refreshing this pivot table takes at least 10-20x as long to complete, in the order of 5-20 minutes, to sometimes taking so long that I give up and kill it by hitting escape a bunch.
It's important to note that I am forced to used Microsoft Query to set up a pivot table in Excel 2003. There is no other way, I believe.
While it is running, Excel just sits there saying "Waiting for data to be returned from Microsoft Query".
Here is the weirdest part. Once the refresh starts, Microsoft Query loads in the background, you can see it on the taskbar. I believe that is expected behavior, but if I click on MS Query and view its datatable, I can see all the data is sitting there.
So what is the hold up? MS Query has the data. Excel is waiting for it to be returned. What is going on? And remember from above, if I do a simple import data to worksheet, MS Query is not used and everything is fast.
So my question is does anybody have any tips/advice on this issue? I need a way to not use MS Query for a pivottable's data source or I need a way to make MS Query not freeze up. I don't get why MS Query needs to be involved in the first place since I am not doing any parameters or so forth.
I created a union query in Access to join two tables (Projections and Actual Sales). The query produces the results I want. I need to create a pivot table in Excel using the union query as the source. When I pull up the data import function in Excel, the union query does not appear. Do I need to do something else? I have tried to create a select query where I select all from the union query and I can find that fine.
When I use this query to create the pivot table the results end up all zeros when I try to sum the values. It creates some crazy results when I show it as count of also.
I can provide the data in either the Access database or Excel spreadsheet.
I have created a pivot table in Excel 2010 that lists amounts used of particular items each month. Inside the pivot table value field settings i have changed the show values as field so that it displays the difference in usage from this month to last.
However if i now select a top 10 filter it only filters by the total number used as opposed to the difference in usage from one month to the next (which is the values displayed).
Is there a way that i can filter by top 10 by the actual values displayed in the pivot chart and not just the underlying data that creates it?
Suppose I have a department List, and I made a list from that column (Department List), and I enter more staff and selected a department for them during registering, now one of the Department List Item change, How is it possible to change all the entry which has that department? For more info see the attachment.