Not able to create Pivot Table, getting error APplication Defined. Please help on this.
VBA Code:
Sub MH()
Dim Macro As Workbook
Dim Macrows As Worksheet
Dim Dataws As Worksheet
Set Macro = Workbooks("Book1.xlsm")
Set Macrows = Macro.Sheets("Sheet11")
Set Dataws = Macro.Sheets("Data")
'Table 1
Macrows.Range("C4:H9").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Data!R1C1:R90C27", Version:=6).CreatePivotTable TableDestination:= _
"Sheet11!R4C3", TableName:="PivotTable10", DefaultVersion:=6
Sheets("Sheet11").Select
Macrows.Cells(3, 4).Select
With ActiveSheet.PivotTables("PivotTable11").PivotFields("WeekNum")
.Orientation = xlRowField
.Position = 1
.Subtotals(1) = False
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Ticket Status")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Resolution SLA Met / Not")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Resolution SLA Met / Not")
.Orientation = xlDataField
.Position = 1
.Function = xlCount
.Name = "Met/Not"
End With
ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlTabularRow
End Sub