Not able to Create Pivot Table

satya12

Board Regular
Joined
Oct 19, 2021
Messages
70
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Your code refers to PivotTable10, PivotTable1, and PivotTable11
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,618
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top