0
所以我已經能夠創建一個數據透視表,我會告訴你我的意思。這是我的代碼到目前爲止。在使用VBA創建數據透視表時遇到問題
Dim WSD As Worksheet
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PRange As Range
Dim FinalRow As Long
Dim FinalCol As Long
Dim StartPT As String
Set WSD = Worksheets("aggregateData")
Set WSD2 = Worksheets("Sheet12")
' Select the data for pivot table
FinalRow = WSD.Cells(Rows.Count, 2).End(xlUp).Row
FinalCol = WSD.Cells(1, Columns.Count).End(xlToLeft).Column
Set PRange = WSD.Cells(2, 1).Resize(FinalRow, FinalCol)
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=PRange)
'Where do I want the pivot table to start
StartPT = WSD2.Range("A1").Address(ReferenceStyle:=xlR1C1)
'Begin to Create the Pivot Table
Set PT = PTCache.CreatePivotTable(TableDestination:=StartPT, TableName:="POS Data")
PT.PivotFields("Fineline").Orientation = xlRowField
End Sub
當我運行這段代碼時,我得到了一個數據透視表的開始。但是,數據透視表顯示爲白色,而不是普通數據透視表所具有的藍色。任何幫助,將不勝感激。
感謝,
摹
嘿,我得到的錯誤「編譯錯誤:命名參數未找到」我使用Excel 2010中,如果這意味着什麼 – GCC
嘗試xlPivotTableVersion14如果您使用Excel 2010中 –
這是突出「版本」,並告訴我說,錯誤 – GCC