F
Fred Smith
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?
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?