Creating Multiple Pivot Tables Using VBA

Apr 1, 2009

I am having a lot of trouble with pivot tables in Excel 2007 VBA. I am trying to create pivot tables using macros (connected to buttons the user can press to create the pivot table) - please don't ask why, but i need to do this!!!

I used the record fuction in excel 2007 to produce macro code which will produce the required pivot tables when the user presses a button.

Unfortuanately the coding seems to work fine when i have one pivot table in a file but breaks down if i record code to produce another pivot table.

I have attached some code below (which was produced by the record function) and is intended to produce 2 seperate pivot tables (the macro submacro2 produces the 1st pivot table and the macro submacro4 lower down the page produces the 2nd pivot table). I have also indicated the point in sub 4 where the code breaks down - basically submacro4 just doesnt run!

View 14 Replies


ADVERTISEMENT

Excel 2010 :: Creating Multiple Tables In VBA And Referring To Newly Created Tables?

Jul 1, 2013

Using Excel 2010. I'm writing a macro that sets up a workbook to be used for estimating at the beginning of a project. In the code I need to create multiple tables (formerly known as "lists") in the workbook. Then later in the code I need to refer back to those newly created tables. Currently, the code that creates the table is part of a loop that creates the table on many different worksheets. The problem of course, is that I have to name the Table, and then it won't create a table of the same name on the next sheet. Then, later in the code, I need to make adjustments to the table that was just created before looping to the next sheet.

Is there a way to create a table without giving it a constant name? Or by giving it a name that builds off of other info in the sheet? For example, I would be good with the naming the table after the sheet name: "Sheet1_Table" or such.

Code:
Sub Auto_Open()
'
Dim sht As Worksheet
If Range("A1") = 1 Then

[Code].....

View 2 Replies View Related

VBA - Creating Pivot Tables In New Sheets Using Dynamic Objects?

Oct 29, 2013

I am trying to solve in VBA how to create pivot tables in new sheets using objects instead of relying on the sheetcounter, which errors out.

I found an old Tip on Mr. Excel: Excel Create and name a new worksheet with VBA

But I can't figure out how to apply the object to the rest of the script. Here is what I have so far:

Sub Macro2()
'
' Macro2 Macro
'
Dim WS As Worksheet
Set WS = Sheets.Add
'

[Code]....

View 1 Replies View Related

Creating Pivot Tables With VBA And Putting In Tabular Form With No Subtotals

Jun 28, 2012

I have created the code below to create a Pivot Table using VBA, so that it populates from a list box option.

I would prefer if it didn't show any subtotals and was in a tabular form. It keeps dropping off at that point for each row field.

CODE
Sub trail()
'
' trail Macro
'
'
Dim wksPivot As Worksheet
Dim wksData As Worksheet
Dim pc As PivotCache
Dim PT As PivotTable
Set wksPivot = Sheets("PIVOT")

[Code] ......

View 2 Replies View Related

Adjust Column Label Selection Multiple Pivot Tables Based On One Pivot Table

Aug 16, 2013

I have a pivot table in the first sheet which includes the field "Date" as a column label.

In the remaining sheets, except for one, there are pivot tables based on the same underlying dataset which also include the field "Date" as a column label.

I would like to adjust the selection (i.e., exclude some dates) from the column label in the first sheet and see if it is possible to make the same adjustments automatically to the pivot tables in the remaining sheets as well.

note that the field "Date" is used as a Column label, i.e., it is not a Report filter.

View 3 Replies View Related

Change Pivot Source Data In Multiple Pivot Tables?

Jan 21, 2013

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.

View 4 Replies View Related

Pivot Table Based Off Multiple Pivot Tables

Sep 5, 2006

Is it possible to create pivot table from another multiple pivot table.

Example: I have two diff pivot table "Income" and "Expense" as well
and I need to preapare new pivot table using with those two pivot table

View 3 Replies View Related

Creating Multiple Word Tables From Excel Data?

Sep 17, 2011

I'm working on a national survey with valuable data from students. The plan is to turn around, 100 different reports to the departments with their respective students.

The issue that I have is creating multiple tables from multiple sheets in excel into a word table, any way of automating it.

What the tables look like in excel:

What I want them to look like in word, with a chart if possible:

I realize that I can just copy and paste easy table into word from excel and with a few clicks of a button, get what I want. But i'm looking for something to automate and simplify this process. There are about 300-400 variables that I need to crosstab with certain demographics.

If it matters any, I bought a software package (Q Market Research) but it doesn't make the tables look exactly how I want them to look. The data is from SPSS, those tables are flat out.

View 9 Replies View Related

Sort Multiple Pivot Tables

Jul 15, 2014

with this macro?

I have a lot of pivot tables on multiple sheets in one workbook.

I want to deselect all "(blank)" from rows, and sort both rows and columns in ascending order.

I recorded a macro but it only refers to specific pivot tables, I would like it to do the same sorting for all pivot tables in the workbook.

Sub PivotBlankSort()
'
' PivotBlankSort Macro
'
'
Windows("Alt Assessment Y10 13-14.xlsx").Activate
Sheets("L&C Prog Sum2").Select
With ActiveSheet.PivotTables("PivotTable10").PivotFields("English")
.PivotItems("(blank)").Visible = False

[Code]...

etc as I move to each separate pivot table.

View 2 Replies View Related

Pivot Tables Multiple Worksheets

Nov 17, 2009

Background: I know ZERO about VBA and I am a Vlookup & Pivot Table noob, but experimenting everyday.

Every week, since August 29, 2009, I get a sales report from my customer in raw form showing point of sales data for the previous 7 days. After manipulating the data I end up with 11 columns.

Now, if I am only concerned with that one week then I can drop the whole sheet into a Pivot Table and all is well.

However, I have 12 sheets now (with more to come), one for each week, and the row count ranges from 3,328 to 16,414.

I do not want to consolidate the data.

I can copy everything to one sheet, and hope not to max out at the million row mark, but would prefer to keep it tabbed by week.

View 2 Replies View Related

Pivot Tables With Multiple Rows?

Sep 21, 2013

This is my data:

This is the Pivot Table I created:

The Pivot Table is exactly what I want and I like that I can also sort by school or district. The problem: Cells B6 through E6 show up with correct information but the totals below that are all wrong. They seem to pull the same data from question 4.

View 3 Replies View Related

Syncing Pivot Tables In 1 Tab And Multiple Tabs

Jan 22, 2014

For data I am using 1 pivot table. I have 4 tabs which use this pivot table to present different data on each tab.

For the first question, I have the same pivot table in the sheet twice in order to have multiple pivot charts with similar data but setup differently. I found this to be the simplest solution to presenting the data in the manner I want to see it. Otherwise I wish to set the tables up so that if I change a filter in one of the tables that the data is automatically updated to both tables.

The second question, this relates to the first question somewhat. I wish to change filters in 1 pivot table from tab one, and once that tab is updated I wish for all of the other tabs with this same pivot table to automatically update with the filter changes from the first time.

View 3 Replies View Related

Control Multiple Pivot Tables With Formula?

Oct 25, 2011

I have 3 different pivot tables (with 3 different data sources) on 3 seperate sheets (sheet2, sheet3 & sheet4). Each pivot table has a report filter which contains employees names. On sheet 1 I have a sort of 'dashboard' set up feeding from the data in the pivot tables, and a combo box form control from which I can select the employees names.

Currently, if I want to see John's data, I need to go to Sheet1 and select 'John' from the report filter, then goto Sheet2 and select 'John' from the report filter & the same for Sheet 3. I was wondering if it is possible to somehow link the pivot tables to the combo box - so that when I select 'John' from the combo box on Sheet1, it automatically selects 'John' in the report filters on sheets 2,3, & 4.

View 9 Replies View Related

Combine Multiple Pivot Tables On One Report?

Apr 21, 2014

I have to track how well location managers are keeping track of skill competencies.

We rate skills as...
0 – know nothing ,
1 – read training manual,
2 – check off by manager.

I need the managers to provide these ratings then I have to report what locations need more training. When an new employee is entered into the system, the manager should give them a target of 2 for each skill the employee needs to gain. If the target skill is 2 rating higher than the current skill level, I have a column named Delta that records a 2.

I have learned how to use the pivot table feature. I can make separate pivot tables using filters that show…
a) how many 2s each employee has for a target,
b) how many 2s each employee has for deltas,
a) how many 2s each employee has for a current level and I can show the date the 2s where achieved

What I need is to learn how to combine all of this information on one pivot table (or report), but the filters really seem to make a mess of it all when it is all together. adding multiple sheets to one Pivot table.

Screenshots...
Count of Targets
Count of Deltas=2
Count of Current Skills
!What I need to produce!

[Code].....

View 1 Replies View Related

Running Multiple Pivot Tables With Same Macro

Aug 31, 2006

I am trying to find a way to set up a macro that will allow me to pull in data - create the Pivot table - delete the table - then pull in fresh data (of a different row length - same number of columns) and create another Pivot table. I have tried to manipulate recorded code to no avail. Here is what I am starting with:

Const lngLastPossRow As Long = 65536
Range(Cells(1, 1), Cells(Cells(lngLastPossRow, 1).End(xlUp).Row, 24)).Name = "Data"

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="Data"). _
CreatePivotTable TableDestination:="", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array(" ", _
"Channel", "Sales/Exchange", "Mode of transp.", "Sold-to Party", "Material", "Data")

While it creates the first pivot table fine, after deleting it and starting again it wants to create the next sequence (PivotTable3) which crashes the macro. I must close the file and reopen to run it again.

View 4 Replies View Related

Filter Multiple Pivot Tables Based On Same Cell Value

Jun 15, 2012

I am trying to update multiple pivot tables from different OLAP cubes based on the same cell value that an user defines,
namely one country for which he/she wants the create the report for. The code I recorded goes like this:

VB:
Sub TUR()

Sheets("Pivot").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("[Geography].[Geography]"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("[Geography].[Geography]"). _
CurrentPageName = "[Geography].&[TUR]"
End Sub

In this example, TUR stands for Turkey.

Basically, I have over 20 countries and at least 3 different OLAP cube-based pivot tables in my report, I can do it with 3 x 20 different macros but that seems like taking the long way.

View 2 Replies View Related

How To Update A Column Label For Multiple Pivot Tables At Once

Aug 24, 2014

I have ~ 300 pivots (one on each tab) all linking to one data set in the same workbook. I realized that I neglected to select the year 2006 in my column label for every pivot table and hoping that there is some way to

simultaneously update all pivots to include 2006 data instead of manually checking the box off one by one.

View 2 Replies View Related

Linking Pivot Tables - Multiple Page Fields

Feb 16, 2010

I have two pivot tables on one sheet and I want the page fields on the second to change when I change the first pivot table. I found the below code and have applied it to one of the three page fields I have, but can't seem to duplicate it for the other page fields:

View 7 Replies View Related

One Slicer For Multiple Pivot Tables With Different Data Source

May 2, 2013

I have multiple pivot tables with different data source. I wish to have one slicer which control all the pivot tables. I would have one common colum for all the pivot tables which is the one i wish to control for instance the person in charge. Note that all my pivot tables are from different data source. how to do it?

View 1 Replies View Related

Update Source Data For Multiple Pivot Tables With VBA

Dec 16, 2013

The spreadsheet is comprised of 4 sales data sheets, one for each store. Each of these sales data sheets runs several pivot tables (One for dept sales, one for waste, one for sales on Selected UPCs etc) and I used to have 1 copy of each pivot table for each store (ie 24 pivot tables). Now I have found a way to have only 1 copy of each PivotTable which changes based on which store is selected using the following code:

Code:
Sheet13.PivotTables ("Top10LW").PivotTableWizard SourceType:=xlDatabase, SourceData:= _
.List(.Value)

This works great however I was repeating it for every pivot table I had in the spreadsheet, causing messy code and file corruptions.

Is there any code which I can use for updating all pivot tables, using as minimal code as possible, all in one hit?

View 3 Replies View Related

Combine Data From Multiple Worksheets - Pivot Tables

Sep 20, 2009

I am trying to combine sorted data from 2 worksheets to a new work sheet to process further. I have one worksheet with order number, part number, order qty but with different delivery dates. On another worksheet, I have the order number too, part number, the qty delivered. The qty delivered is not always the same each delivery.

My aim is to find out how many are already delivered under a certain purchase order and the balance of undelivered parts.

I used pivot tables to sort out the data but I am stuck here not knowing how to extra the sorted data from the pivot tables to the 3rd worksheet. I will need to match the order number and the part number.

View 9 Replies View Related

Multiple Pivot Tables - Single Table Of Source Data

Mar 9, 2014

I am trying to generate several pivot tables from one data source table. I have successfully created my first pivot table (A date field, and a water storage facility level reading) and subsequently a graph from this. I have worked out that I need to group my dates as I am supplied a daily reading, but only need monthly average. All worked great.

Now i need to create more pivot tables and graphs. The next one I want is to create one grouped by years. But when I create this new pivot table and change the grouping of the date field to yearly, it also changes the grouping on my first pivot table, which is undoing my work.How to tell excel that these pivots are independent, and I don't want them changing in unison? See screen grab of my source data and where I am up to...

Microsoft Excel - 401027_0100.00_0221.00.csv_2014-03-10_11-41-35.jpg

View 1 Replies View Related

Creating Pivot Table From Multiple Sheets

Jan 15, 2014

I 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 Related

Creating A Pivot Table With Multiple Sheets

Apr 23, 2008

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")

View 9 Replies View Related

Refresh Pivot Tables Linked To Pivot Table

Jul 25, 2006

I currently have several pivot table that's linked to a single pivot table(let's call it X) in the same workbook. I'm doing this to limit the file size because the data in X comes from a text file that has millions of lines. However, it's such a pain every time I need to update the tables because simply clicking "refresh" does not update those tables that are linked to X with new data. I would have to instruct the wizard in every linked table to point to X every time. I'm trying to write a small program to re-point to X for each of those other pivot tables whenever i refresh data. However, after trying to record the steps to do this I'm still unable to run these

Sub Macro1()

ActiveSheet.PivotTableWizard SourceType:=xlPivotTable, SourceData:= _
"PivotTable1"

End Sub

View 6 Replies View Related

Can Pivot Table Be Created From Several Other Pivot Tables

Mar 5, 2014

I have 12 months worth of data in twelve separate workbooks each with a pivot table, I have copy/moved the pivot table tab from each into one workbook so now I have a workbook that consists of 12 tabs each with a pivot table. What I would like to be able to do is create a summary table with the full years data; where I am running into problems is that each months table has slightly different row and column counts and labels making any formula like =sum([sheet 1 cell a1]+[sheet 2 cell a1]) problematic.

View 3 Replies View Related

Pivot Tables: Pivot Table Layout

Oct 14, 2003

if there is a way to display a table as column percentages but have the totals as raw numbers.

View 9 Replies View Related

Show All Pivot Items In Pivot Tables

Jun 19, 2008

I've got 4 pivot tables (all derived from the same base data) on 4 separate worksheets. I've been able to (with this help of this site) to use VBA to hide pivot items on all of these sheets using a list on a user form. Hide/Show Pivot Table Field Items. Hide Pivot Table Fields Pivot Items by Criteria

I now need to be able to show all the pivot items on only 3 of the 4 pivot tables, with the 4th pivot table being left untouched. For ease assume that my sheets are sheet1, sheet2, sheet3, and sheet4. The tables I wish to update are on sheet2, sheet3 and sheet4. The pivot table on each sheet is called "PivotTable4" and the pivot item is called "Business". The pivot item contains 12 business names (Business1, Business2 etc etc)

Is there an easy way of doing this? I've spent the day looking through the internet and various "Dummies" books but with little success, I fear that I'm obviously below even Dummy level

View 5 Replies View Related

Creating Tables In Spreadsheet Won't Let To Insert New Row?

Apr 17, 2014

sample worksheet Antligen.xls

I have a spreadsheet that I need to add new rows everytime I have a new client. I a formula in the N column and a formula in the F column that I would like to automatically insert itself into the new rows.

The problem is this: I have arranged my table so that I can look at clients alphabetically, and according to other date... BUT now it wont let me insert a new row when I have a new client!!!

Is there anyway of keeping it so that I can insert a new row into my table, but preserve all of the formulas that I want automatically put into both the F and N column?

Attached is the sample spreadsheet.

View 1 Replies View Related

Creating Table From Data From Several Other Tables

Jan 10, 2014

My family owns a Fast Casual Middle Eastern/ Mediterranean Restaurant. I'm taking charge of making it as profitable as can be! Our plates are different combinations of kebabs, rice, Falafels, Gyros, salad, platters. So theirs tons of combinations.

I am Dead serious about knowing REAL plate costs:

I spent days entering price data, weighing meat, produce, calculating usable yields. I then built "component builders" using data validation drop-downs, and Index + Match functions to construct the costs of the recipe items,standard base items and side items. So I now know How much a skewer of Marinated Kebab Costs me, and all the Components that go into building a plate.

I've now built a "Plate Builder" (See Pic) to create the EVERY combination available at our restaurant. So when I'm done filling in all the builders, I'll have a whole lot of tables. I'd like to pull the name and plate cost from each table and create a big table organized by whether its eat in or take out. How do I do it.

TL;DR: Need to create a table that pulls data from several other tables....

View 2 Replies View Related







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