Getting Run Time Error 5 When Creating A Pivot Table
Jun 11, 2008I am creating 10 pivot tables for data in one worksheet and putting them in a separate work sheet. i used the macro recorder but the cod eit worte stop at this line ...
View 9 RepliesI am creating 10 pivot tables for data in one worksheet and putting them in a separate work sheet. i used the macro recorder but the cod eit worte stop at this line ...
View 9 RepliesIn creating a macro and creating a pivot table as one of the first steps, I get this runtime error in visual basic:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"original working!R1C1:R1000C13", Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="Sheet4!R3C1", TableName:="PivotTable2" _
, DefaultVersion:=xlPivotTableVersion14
I keep running into this error when I try to create a pivot table.
The debugger highlights the following line:
I have the following code to create a pivot table in VBA
Sheets("test").Activate
Dim data As Range
Set data = Range(Cells(1, 1), Cells(1, 1).End(xlDown).End(xlToRight))
Set pt = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="data").CreatePivotTable(TableDestination:=Sheets("summary").Cells(1, 1), TableName:="ItemList")
When I run this I get the error message Runtime error 1004: Reference not valid.
There is something in the "set pt=....." that it does not like.
I would create a field in Access that would have the Names of the Counties (for my Row Labels) and I would create a field that would contain Years (for Column Labels) rather than using each individual date from my database. I want to be able to do this on the run in a Pivot Table.
For my Row Labels I am using the Municipalities in Wisconsin. Each one is assigned a number such as: 67-251, 67-015, 67-123. The "67" identifies the County and the "251" or "015" identifies the City, Town or Village. We need to use the whole number for the Rows but we only want to use the first 2 Digits to sort by the County. 67 is Waukesha County as is 40 Milwaukee County. I want to total the county's using the first two digits of their name. The field is called "SC" and it's a 6 char text field.
For my Column Labels I have many different dates that span a period of about 15 years. I would like to only use the Year for my Column Labels. And that year would accumulate all the dates for that County for the year I want to use..
In the end I would like to be able to get a Count of Permits for each County by Year. I would also like to be able to specify only certain years that I might want to see data for. Every time there is a date in the "First" field that is a count one home for the "SC" field.
I used to be really savvy with Quatro Pro, most people don't even know what that is anymore. In that program I had a line of text where I would enter the criteria that I was interested in for my Table. Such as 51, 40, 45, 60, 67 would be the counties I want to use. 2000, 2002, 2005 would be the column values I want to use.
I have a table (attached example with only a SMALL part of all data) I would like to transform this into pivottable format without copying and pasting. In row 2, all of the numbers pertain to years. Column B has the number of years in force for each property account (Column A). I
View 2 Replies View RelatedCreating a pivot table using a macro ...
View 9 Replies View RelatedI am trying to create a single pivot table using data from multiple sheets (one per month). I am trying to summarise the headcounts (count of assignment number) by month in a single table and then be able to select single months/areas or combination of months/areas in the same way as a single sheet pivot table. I have managed to get the table part way there but it’s not counting the assignment number and my Jan data is not appearing (see attached). How do I fix this? (I have only used 5 months of year in example due to the large file size) Alternatively is there a different or better way to this other than pivot table?
View 2 Replies View RelatedI have the code listed below where i keep getting a compile error. This is from a You Tube (Pivot Macro - Episode 1211 - YouTube) episode 1211. why this would not work? Basically trying to set up a macro that creates a Pivot Table that will always have the same number of columns, but each set of data will have different number of rows.
ActiveWorkbook.PivotCaches.Create(SourceType: xlDatabase, SourceData:
DataSheet & "!R1C1:R" & FinalRow & "C37", Version: xlPivotTableVersion14).CreatePivotTable
TableDestination: NewSheet & "!R3C1", TableName: "PivotTable2", DefaultVersion: xlPivotTableVersion14
I am trying to create a pivot table using multiple sheets. I looking for some code that will replace the "consolidated ranges" in the Pivot Table Wizard. I am looking for code because I am writing a macro that will create a different number of worksheets in the Workfile, depending on which dataset I use. i.e File 1 may have 75 worksheets, whereas File 2 may have 120 worksheets. '
The ranges on each of the worksheets will be the same. Range("A2:Av48")
Basically I've jumped straight in and have tried to recreate a report I need to produce which requires a pivot table. I have managed to create the code I need to produce a pivot table in a new sheet with all of the headers available for analysis. Where I'm struggling is in getting the pivot to show the datafields correctly.
The list that I am creating the pivot from has about 30 headers. 20 or so are analysis fields with the remainder being various figures; monthly plan, monthly actual, monthly variance etc..
The pivot table I need to create needs all analysis fields available to the end user for manipulation, which I have managed to do. I have created rows for sales areas, also with no problem. It also needs the above plan, actual and variance fields in columns and as datafields. This is where I'm having trouble. When I create the pivot manually it ends up with 1 row and 3 separate columns with summed data in each. I have checked the VBA code, copied it and used it again. The pivot table comes out with 1 row but with the data fields stacked one on top of each other. Any minor alterations that I can think of, (for example adding a position = 1, position = 2 etc.), either creates a chaotic looking sheet or an error.
I've checked various posts on pivot tables but am having trouble understanding the way in which I can correct this. Is there a straightforward command that I'm missing? Do I need to start declaring variables for pivot items?
I was wondering if it is possible to create a custom pivot table report filter? I would like to take an existing pivot table report filter and manually add values into it. I would like to do this because I have multiple pivot tables, some with the same values and some with different values and I have a VBA code from Contextures that applies a mass filter to all fields with the same name. So if i could manually add values into one report filter, I could filter from one location and have all my pivot tables update at the same time if they contain the value that i would like to filter by.
View 1 Replies View RelatedI want to create a report using power pivot while creating the relationship between the linked tables, power pivot is throwing error "The relationship cannot be created because each cilumn contains duplicate values. Select at least one column that contains only values"
View 1 Replies View RelatedI am trying to run the macro below but keep getting Error 5, any ideas why this is at all.
Sub Quarterly07()
Dim PTCache As PivotCache
Dim PT As PivotTable
'Create the cache
Set PTCache = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDateBase, SourceData:=Range("A1").CurrentRegion)
' Add a new sheet for the pivot table
Worksheets.Add
'Create the pivot table
Set PT = ActiveSheet.PivotTables.Add( _
PivotCache:=PTCache, _
TableDestination:=Range("A4"))
Upon opening an existing file, I receive the following error: Unable to Read File….I then click OK, Enable the macros and upon doing so, the following message appears: Excel Table Report on [Sales] Sheet1 was discarded due to integrity problems.
I have two Pivot tables on the report – Pivot8 and Pivot1 – two separate worksheets but using the same source data. I have placed a button on each worksheet to enable the user to refresh the Pivot Table. Pivot1 is the table that is being discarded and when I click the button on Sheet1, the following Run time error 1004 appears: Unable to get the Pivot Tables property of the Worksheet class….when I select Debug, here’s the code with the bolded section being the point of error:
ActiveSheet.Unprotect Password:="test"
Range("K9").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("K9").Select
Selection.Copy
Range("K9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Why does the following code give me a runtime error on the first statement?
Code:
Sub pt()
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"'Data-Consolidation (2)'!Source_Data", Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="Data-Consolidation (2)!R1C6", TableName _
:="PivotTable9", DefaultVersion:=xlPivotTableVersion12
[Code] ............
I am trying to get some averages using pivot tables. However, whenever I set up my pivot table and then go to field settings and pick average, all I get are # DIV/0 errors in all the boxes where there were numbers.
View 4 Replies View RelatedI am trying to to a vlookup on a pivot table and keep getting an error message (The error states that The formula you have entered contains a error) and excel will highlight the 0 in my formula. The formula is
=IF(ISERR(VLOOKUP(G17,'Curr Month'!$G:$H,2,FALSE)=TRUE,0,VLOOKUP(G17,'Curr Month'!$G:$H,2,FALSE)
I randomly created this spreadsheet as an example, but what I need is to display the start and end time to this sheet in a summary report format i.e.,
Location
(Date)
(Truck#) (Miles) (Stops) (Start time) (End Time)
etc...
etc...
The problem is that the table seems to always summarizes the time as well or it gives a count value of the time. If there is a better way or method to do this, I have open arms
I created a custom formula for a pivot table.the existing columns are weekly averages.I made a formula to calculate the average of 5 individual weeks.But when one of the value is blank.Blank cell is considered as zero.and hence the final average is wrong.
View 2 Replies View RelatedI am trying to group some dates in a pivot table.
Unfortunately I receive an error saying it can't group the selection.
I have done "text to columns" and made the cells - (date values) and I have had no luck.
As I am at work I can't use the HTML genie because it won't install but I have uploaded a dummy file to my dropbox which available from here [URL] .......
I pull this data from an Oracle POWER PIVOT and always have trouble grouping the dates when they come from Power Pivot. Currently working as analyst so figuring this out would make life so much easier as I could group by months etc.
Below is some code I am trying to run. What I would like to do is select a certain "data row" in the pivot, and apply some conditional formatting to that. It works just fine until I reach the .colorindex = 3 line. It says I'm getting an application/object defined. how to fix this? I'm on Excel 2007. This was fine on 2000!
pvtCurrent.PivotSelect "'% Dist'", xlDataAndLabel
With Selection
With .Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
With .FormatConditions.Add(xlCellValue, xlBetween, "0", "0.97")
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
End With
why when pivot tables display individual or single time values they are rounded up or down. i.e. a value of 1:31.5 is displayed in the pivot table as 1:35.0 etc. I have tried custom formatting the table itself but to no avail.
View 3 Replies View RelatedI 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.
I have to generate a report using a pivot table, that tells me what work was done on time and what was late. Entering a formula outside the pivot table sees the scheduled start date drop downs as "blank" and says they are late when they are not. I cannot seem to use the value fields when I try to create a calculation field within the table. I use 2010 at work, 2007 at home.
sep 11-17
FGHIJK10Count of WO No.
=IF(G12>=H12, I12," ")=IF(G12
Excel 2007
No empty rows
No empty cells
No calculations in cells
Field names look fine - no punctuation no merged cells
If I select one column - any single column I can generate a pivot table but not with multiple columns
I am using a Pivot Table to search for keywords in a subject line and it will display results if that keyword appears in the Pivot Table.
What I want to be able to do is copy 30 cells of that Pivot Table at a time into a new Workbook. All that I want to copy is Column A(Case Number) and Column B(Subject Line) of the Pivot Table.
Example:
Total Pivot Table data is 1000
I search for "Crashing", this will display 100 records
I want to grab the first 30 records and copy them into a new workbook
I want to grab the next 30 records and copy them into a new workbook
I want to grab the next 30 records and copy them into a new workbook
I want to grab the remaining 10 records and copy them into a new workbook
I am trying to adapt a macro to run on data that is consistently in the same format but the data does change, the macro needs to run over and over on new excel workbooks, dynamic range ? instead of a set source ?
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"weekly71012!R1C1:R9379C30", Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable1" _
, DefaultVersion:=xlPivotTableVersion14
I am sure this is the problem as i initially created the macro using weekly71012 excel file however i just want it to run on every file i pull it off?
In the "Pivot Table Field List" I have the option to "Choose fields to add to report". I have a large number of fields that I want to choose and "Add to Values" - so it is tedious to select each item individually.My question: Is there any possible way select multiple fields at the same time? e.g.
a "select all" option, orhighlighting a range of the available fields (either by dragging or holding the shift key)I've looked / tried above with no luck.
Any Excel Add-Ins out there that might address this? I'm fearing not since my searches have come up empty.
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.