Dim oCache As PivotCache
Set oCache = ThisWorkbook.PivotCaches.Add(xlDatabase, "Sheet1!R1C1:R5C3")
Dim oSheet As Worksheet
Set oSheet = ThisWorkbook.Worksheets.Add
Dim oRange As Range
Set oRange = oSheet.Range("A1")
Dim oTable As PivotTable
Set oTable = oCache.CreatePivotTable(oRange, "PivotTable")
ActiveSheet.PivotTables("pivottable11").SmallGrid = False
Charts.add
ActiveChart.SetSourceData Source:=Sheets("sheet1").Range("E3")
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart.PivotLayout.PivotFields("工作")
.Orientation = xlRowField
.Position = 1
End With
With ActiveChart.PivotLayout.PivotFields("工作时间")
.Orientation = xlDataField
.Position = 1
End With
With ActiveChart.PivotLayout.PivotFields("负责人")
.Orientation = xlColumnField
.Position = 1
End With