下面的子程序就像Windows版Excel 2016上的冠军一样,但我有一个用户试图在她的Mac上运行它并且它会抛出错误。我没有错误的屏幕截图,但是当她发送给我时,我会在这里发布。
我为这个用户写了几个其他的宏,所以我知道她一般不会遇到任何麻烦这样的问题。这是宏的特定之处。在Mac版本中生成数据透视表的代码是不同的吗?
Private Sub PivotCreate()
Sheets("IndirectPivot").Select
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Indirect Import!R1C1:R1048576C4", Version:=6).CreatePivotTable _
TableDestination:="IndirectPivot!R1C1", TableName:="PivotTable4", _
DefaultVersion:=6
Sheets("IndirectPivot").Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Funder")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable4").PivotFields("GL")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Class")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
"PivotTable4").PivotFields("Amount"), "Count of Amount", xlCount
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Count of Amount")
.Caption = "Sum of Amount"
.Function = xlSum
.NumberFormat = "0.00"
End With
ActiveSheet.PivotTables("PivotTable4").RowAxisLayout xlTabularRow
ActiveSheet.PivotTables("PivotTable4").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable4")
.ColumnGrand = False
.RowGrand = False
End With
ActiveSheet.PivotTables("PivotTable4").PivotFields("Funder").Subtotals = Array( _
False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable4").PivotFields("GL").Subtotals = Array( _
False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable4").PivotFields("Amount").Subtotals = Array( _
False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables("PivotTable4").PivotFields("Class").Subtotals = Array( _
False, False, False, False, False, False, False, False, False, False, False, False)
With ActiveSheet.PivotTables("PivotTable4").PivotFields("GL")
.PivotItems("(blank)").Visible = False
End With
End Sub