Maximum Number of Fields in Pivot Table?? -WEIRD!

jswhip

Board Regular
Joined
Jan 19, 2005
Messages
69
I have a confusing VBA problem/bug that I don't know how to work around.

1. I define a pivot cache with 70 columns (this works fine)
2. However, I need 71 columns or else the calculated field I need won't show up in the field list.
3. But, Excel 2007 won't let me add a 71st column.
4. I've tried using dynamic/static ranges for the cache, but neither solved the problem.

I use the original source data to create multiple pivot tables on separate sheets - would this be the reason why I can't add another calculate field? The reason I ask is that the original source only has 36 columns, but in the course of adding calculated fields, I've had to expand the cache.

Dim WSD As Worksheet
Dim pc As PivotCache
Dim PT As PivotTable
Dim PRange As Range
Dim FinalRow As Long
Dim FinalCol As Long

Set WSD = Worksheets("Raw Data")

FinalRow = WSD.Cells(Rows.Count, 1).End(xlUp).Row
FinalCol = WSD.Cells(1, Columns.Count).End(xlToLeft).Column
Set PRange = WSD.Cells(1, 1).Resize(FinalRow, FinalCol + 1)

' Set pc = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
' "Raw Data!R1C1:R100000C70", Version:=xlPivotTableVersion12)


Set pc = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="'" & WSD.Name & "'!" & PRange.Address(, , xlR1C1))

Set PT = pc.CreatePivotTable(TableDestination:=Sheets("Pivot Table 9").Range("A1"), TableName:= "PivotTable1", DefaultVersion:=xlPivotTableVersion12)

With PT

.CalculatedFields.Add "ROLL_3_MO_AUM%", "=IF('ROLL_3_MO_AUM' >0,'ROLL_3_MO_AUM+')/'ROLL_3_MO_AUM',"""")", True


.
.
.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
That calculated field definition has unbalanced brackets. Wouldn't that cause a problem?
 
Upvote 0
Thanks.

I noticed that after numerous iterations. It's odd that it didn't flag a syntax error when I tried to execute the code.

NICE CATCH!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top