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