VBA录制宏 同样的表格出现438错误
SubMacro2()''Macro2Macro'宏由macbookpro录制,时间:2017/11/18''Columns("A:H").SelectActiveWin...
Sub Macro2()
'
' Macro2 Macro
' 宏由 macbookpro 录制,时间: 2017/11/18
'
'
Columns("A:H").Select
ActiveWindow.ScrollRow = 1
With ActiveWorkbook
.PivotCaches.Add SourceType:=xlDatabase, SourceData:="=汇总!C1:C8"
.PivotCache.CreatePivotTable TableDestination:="=汇总!C10:C23", TableName:="数据透视表5", DefaultVersion:=1
End With
Range("J1").Activate
With ActiveSheet.PivotTable.PivotField
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTable.PivotField
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTable.AddDataField Field:=ActiveSheet.PivotTable.PivotField
Columns("J:K").Select
Selection.Copy
Range("L1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlPasteSpecialOperationNone, SkipBlanks:=False, Transpose:=False
With Selection
.EntireColumn.Hidden = False
.ColumnWidth = 17.200001
End With
Range("L3:M103").Select
ActiveWindow.ScrollRow = 2 展开
'
' Macro2 Macro
' 宏由 macbookpro 录制,时间: 2017/11/18
'
'
Columns("A:H").Select
ActiveWindow.ScrollRow = 1
With ActiveWorkbook
.PivotCaches.Add SourceType:=xlDatabase, SourceData:="=汇总!C1:C8"
.PivotCache.CreatePivotTable TableDestination:="=汇总!C10:C23", TableName:="数据透视表5", DefaultVersion:=1
End With
Range("J1").Activate
With ActiveSheet.PivotTable.PivotField
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTable.PivotField
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTable.AddDataField Field:=ActiveSheet.PivotTable.PivotField
Columns("J:K").Select
Selection.Copy
Range("L1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlPasteSpecialOperationNone, SkipBlanks:=False, Transpose:=False
With Selection
.EntireColumn.Hidden = False
.ColumnWidth = 17.200001
End With
Range("L3:M103").Select
ActiveWindow.ScrollRow = 2 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询