0
我是新來的編碼。我試圖執行下面的代碼,但excel總是彈出這兩個錯誤:VBA中的錯誤混淆
「運行時錯誤1004:object'_global的方法'範圍'失敗。」
和
「應用 - 定義或對象 - 定義的錯誤」。
我的代碼有什麼問題?
Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable
Set PTCache = ActiveWorkbook.PivotCaches.Create(_
SourceType:=xlDatabase, _
SourceData:=Range(「A1」).CurrentRegion)
Worksheets.Add
Set PT = ActiveSheet.PivotTables.Add(_
PivotCache:=PTCache, _
TableDestination:=Range(「A3」))
With PT
.PivotFields(「Region」).Orientation = xlPageField
.PivotFields(「Month」).Orientation = xlColumnField
.PivotFields(「SalesRep」).Orientation = xlRowField
.PivotFields(「Sales」).Orientation = xlDataField
.DisplayFieldCaptions = False
End With
End Sub
我回答這個昨天:看到這個答案】(http://stackoverflow.com/a/35742622/4240221) –