- 帖子
- 9
- 主題
- 4
- 精華
- 0
- 積分
- 13
- 點名
- 0
- 作業系統
- window7
- 軟體版本
- office 2010
- 閱讀權限
- 10
- 性別
- 女
- 來自
- HsinChu
- 註冊時間
- 2013-10-14
- 最後登錄
- 2014-6-26
|
本帖最後由 GBKEE 於 2013-10-16 14:46 編輯
利用 VBA 寫 PIVOT 無法指定CREATE 到 SHEET 2, 請問是哪裏有問題.
會一直卡在
Set PT = PTCache.CreatePivotTable _
(TableDestination:=sheets("pivot2").range("A1"), TableName:="PivotTable1")
========================================
Sub crePT()
Dim PTCache As PivotCache
Dim PT As PivotTable
Windows("AA").Activate
'Sheets("Sheet2").Name = "Pivot2"
Set used1 = Sheets("details").UsedRange
Set PTCache = ThisWorkbook.PivotCaches.Add _
(SourceType:=xlDatabase, _
SourceData:=used1)
Set PT = PTCache.CreatePivotTable _
(TableDestination:=sheets("pivot2").range("A1"), TableName:="PivotTable1")
With PT
.PivotFields("Product").Orientation = xlRowField
.PivotFields("account").Orientation = xlRowField
.PivotFields("FSE/FPE").Orientation = xlRowField
.PivotFields("OT").Orientation = xlDataField
End With
Application.CommandBars("PivotTable").Visible = False
End Sub |
|