|
运行显示1004错误,显示红色部分有问题,请帮忙,多谢!
Sub tubiao() Dim Myr%, nsht$, nchtnm$ Sheets("Sheet2").Select Myr = [a65536].End(xlUp).Row Range("E1:J" & Myr).Select Selection.Name = "data1" ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "data1").CreatePivotTable TableDestination:="", TableName:= _ "数据透视表1", DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTables("数据透视表1").AddFields RowFields:="班组", ColumnFields:= _ Array("部件名称", "返工内容", "责任单位") nsht = ActiveSheet.Name ActiveSheet.PivotTables("数据透视表1").PivotFields("数量").Orientation = xlDataField ActiveWorkbook.ShowPivotTableFieldList = True ActiveSheet.PivotTables("数据透视表1").PivotFields("返工内容").Subtotals = Array(False, _ False, False, False, False, False, False, False, False, False, False, False) Charts.Add nchtnm = ActiveChart.Name ActiveChart.SetSourceData Source:=Sheets(nsht).Range("C5") ActiveChart.Location Where:=xlLocationAsNewSheet ActiveWorkbook.ShowPivotTableFieldList = False Application.CommandBars("PivotTable").Visible = False Sheets(nsht).Visible = 0 Sheets(nchtnm).Select End Sub |
|