Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Pivot table from a pivot table

I'm trying to create a pivot table from an existing pivot table.

My pivot table is in the range of A1:N484. It's a list of clients and their
total assets. I've added column O which categorizes each client based on
their assets. Now I want a pivot table by category.

My code is:

Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
Sheets("Households").Range("A2", "O483").Address)
Set PT = PTCache.CreatePivotTable(TableDestination:="", _
TableName:="AssetLevels")

But VBA gives me an error 1004 at the "Set PT" statement. PTCache is defined
as a PivotCache, and PT is a PivotTable. If it makes any difference, the
same variables were use to create the original pivot table.

I find VBA help frustrating, because when I lookup the Add method of
PivotCaches, it says the first parameter is the type of data and can be
xlConsolidation, xlDatabase, xlExternal, xlPivotTable or xlScenario. But it
doesn't say where each option applies. I know I don't have xlEternal, but it
might be one of the others. Is that my problem?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Pivot table from a pivot table

Instead of creating another pivot table, you could calculate the
category in the data source table.

In the data source table, add a column in which you use SUMIF, or
SUMPRODUCT to total the assets for each customer. In another column, use
a VLOOKUP formula to calculate the category.

Add the category field to the pivot table.

Fred Smith wrote:
I'm trying to create a pivot table from an existing pivot table.

My pivot table is in the range of A1:N484. It's a list of clients and their
total assets. I've added column O which categorizes each client based on
their assets. Now I want a pivot table by category.

My code is:

Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
Sheets("Households").Range("A2", "O483").Address)
Set PT = PTCache.CreatePivotTable(TableDestination:="", _
TableName:="AssetLevels")

But VBA gives me an error 1004 at the "Set PT" statement. PTCache is defined
as a PivotCache, and PT is a PivotTable. If it makes any difference, the
same variables were use to create the original pivot table.

I find VBA help frustrating, because when I lookup the Add method of
PivotCaches, it says the first parameter is the type of data and can be
xlConsolidation, xlDatabase, xlExternal, xlPivotTable or xlScenario. But it
doesn't say where each option applies. I know I don't have xlEternal, but it
might be one of the others. Is that my problem?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Pivot table from a pivot table

Thanks Debra,

I thought of that, and it would solve part of problem. But I'm really
looking for the number of clients in each category. In the source data
table, a client could have 6 different accounts. I could use your suggestion
to categorize them, but how do I count them? If I count in a pivot table
from the original data source, it's going to use 6 rather than 1. Is it
possible to count the unique entries in a data source?

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Debra Dalgleish" wrote in message
...
Instead of creating another pivot table, you could calculate the
category in the data source table.

In the data source table, add a column in which you use SUMIF, or
SUMPRODUCT to total the assets for each customer. In another column, use
a VLOOKUP formula to calculate the category.

Add the category field to the pivot table.

Fred Smith wrote:
I'm trying to create a pivot table from an existing pivot table.

My pivot table is in the range of A1:N484. It's a list of clients and

their
total assets. I've added column O which categorizes each client based on
their assets. Now I want a pivot table by category.

My code is:

Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
Sheets("Households").Range("A2", "O483").Address)
Set PT = PTCache.CreatePivotTable(TableDestination:="", _
TableName:="AssetLevels")

But VBA gives me an error 1004 at the "Set PT" statement. PTCache is

defined
as a PivotCache, and PT is a PivotTable. If it makes any difference, the
same variables were use to create the original pivot table.

I find VBA help frustrating, because when I lookup the Add method of
PivotCaches, it says the first parameter is the type of data and can be
xlConsolidation, xlDatabase, xlExternal, xlPivotTable or xlScenario. But

it
doesn't say where each option applies. I know I don't have xlEternal,

but it
might be one of the others. Is that my problem?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pivot table from a pivot table

=SUMPRODUCT(1/COUNTIF(A1:A15,A1:A15))

if there are no empty cells in the specified. range.

--
Regards,
Tom Ogilvy


Fred Smith wrote in message
...
Thanks Debra,

I thought of that, and it would solve part of problem. But I'm really
looking for the number of clients in each category. In the source data
table, a client could have 6 different accounts. I could use your

suggestion
to categorize them, but how do I count them? If I count in a pivot table
from the original data source, it's going to use 6 rather than 1. Is it
possible to count the unique entries in a data source?

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Debra Dalgleish" wrote in message
...
Instead of creating another pivot table, you could calculate the
category in the data source table.

In the data source table, add a column in which you use SUMIF, or
SUMPRODUCT to total the assets for each customer. In another column, use
a VLOOKUP formula to calculate the category.

Add the category field to the pivot table.

Fred Smith wrote:
I'm trying to create a pivot table from an existing pivot table.

My pivot table is in the range of A1:N484. It's a list of clients and

their
total assets. I've added column O which categorizes each client based

on
their assets. Now I want a pivot table by category.

My code is:

Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
Sheets("Households").Range("A2", "O483").Address)
Set PT = PTCache.CreatePivotTable(TableDestination:="", _
TableName:="AssetLevels")

But VBA gives me an error 1004 at the "Set PT" statement. PTCache is

defined
as a PivotCache, and PT is a PivotTable. If it makes any difference,

the
same variables were use to create the original pivot table.

I find VBA help frustrating, because when I lookup the Add method of
PivotCaches, it says the first parameter is the type of data and can

be
xlConsolidation, xlDatabase, xlExternal, xlPivotTable or xlScenario.

But
it
doesn't say where each option applies. I know I don't have xlEternal,

but it
might be one of the others. Is that my problem?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Pivot table from a pivot table

Your post was enough to solve my problem. I ended up using:

=1/countif($A:$A,A2)

and copied down. But I'm curious. Was the second 'A1:A15' a typo, or does it
have an application somewhere? And why use SUMPRODUCT? I don't see what
value it adds.

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Tom Ogilvy" wrote in message
...
=SUMPRODUCT(1/COUNTIF(A1:A15,A1:A15))

if there are no empty cells in the specified. range.

--
Regards,
Tom Ogilvy


Fred Smith wrote in message
...
Thanks Debra,

I thought of that, and it would solve part of problem. But I'm really
looking for the number of clients in each category. In the source data
table, a client could have 6 different accounts. I could use your

suggestion
to categorize them, but how do I count them? If I count in a pivot table
from the original data source, it's going to use 6 rather than 1. Is it
possible to count the unique entries in a data source?

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Debra Dalgleish" wrote in message
...
Instead of creating another pivot table, you could calculate the
category in the data source table.

In the data source table, add a column in which you use SUMIF, or
SUMPRODUCT to total the assets for each customer. In another column,

use
a VLOOKUP formula to calculate the category.

Add the category field to the pivot table.

Fred Smith wrote:
I'm trying to create a pivot table from an existing pivot table.

My pivot table is in the range of A1:N484. It's a list of clients

and
their
total assets. I've added column O which categorizes each client

based
on
their assets. Now I want a pivot table by category.

My code is:

Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, _
Sheets("Households").Range("A2", "O483").Address)
Set PT = PTCache.CreatePivotTable(TableDestination:="", _
TableName:="AssetLevels")

But VBA gives me an error 1004 at the "Set PT" statement. PTCache is

defined
as a PivotCache, and PT is a PivotTable. If it makes any difference,

the
same variables were use to create the original pivot table.

I find VBA help frustrating, because when I lookup the Add method of
PivotCaches, it says the first parameter is the type of data and can

be
xlConsolidation, xlDatabase, xlExternal, xlPivotTable or xlScenario.

But
it
doesn't say where each option applies. I know I don't have

xlEternal,
but it
might be one of the others. Is that my problem?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Copying values from pivot table to cells outside pivot table richzip Excel Discussion (Misc queries) 4 January 16th 08 11:03 PM
Filter lines with Pivot table and non pivot table columns Grover Charts and Charting in Excel 4 September 28th 07 03:16 AM
Filter lines containing pivot table and non pivot table data Grover Excel Worksheet Functions 0 September 24th 07 07:20 PM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


All times are GMT +1. The time now is 10:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"