0
我想創建一個VBA腳本來創建數據透視表,但不幸的是它不工作。創建數據透視表不工作
整個腳本如下:
Sub SeparateBrandNonBrand()
'
' Last Months Data Summary
'
'
Dim PT As Excel.PivotTable
Set PT = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"2013-10-28!R1C1:R200000C20", Version:=xlPivotTableVersion1).CreatePivotTable(_
TableDestination:="'Data-Summary'!R1C1", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion1)
With PT
With .PivotFields("Sites")
.Orientation = xlRowField
.Position = 1
End With
With .PivotFields("campagin")
.Orientation = xlColumnField
.Position = 1
End With
.AddDataField .PivotFields("visits"), "Sum of visits", xlSum
End With
End Sub
但是特別在運行時腳本抱怨說,代碼的以下部分是無效的(無效的過程調用或參數)。
Set PT = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"2013-10-28!R1C1:R200000C20", Version:=xlPivotTableVersion1).CreatePivotTable(_
TableDestination:="'Data-Summary'!R1C1", TableName:="PivotTable1", _
DefaultVersion:=xlPi
votTableVersion1)
有沒有人有什麼想法可能會出錯?