PIVOT TABLES ERROR

S

SID

I keep getting Appliction defined or object defined error when I run the
following code. My obljective is to have a variable source data range, so
when new data is added the pivot table will be able to pick it up. Help.
Thanks.

Sub creatpivot_table()
Dim PTCache As PivotCache
Dim PT As PivotTable

Set PTCache = ActiveWorkbook.PivotCaches.Add _
(SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion.Address)


Set PT = PTCache.CreatePivotTable(TableDestination:="",
TableName:="PivotTable4")

With PT
..PivotFields("CARDMEMBER_NAME").Orientation = xlRowField
..PivotFields("BILLING_AMOUNT").Orientation = xlDataField
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top