Guys,

Please find the attachment that contains the table. I am trying to create a pivot table using VBA but its throwing me error can some one help me out in this...

this is my code


Private Sub bs_rin_pivot_table()
    
    Dim objTable As PivotTable, objField As PivotField
    Dim ws As Worksheet
    
    Set ws = ActiveWorkbook.Sheets("Sheet2")
    ActiveWorkbook.Sheets("RIN").Select
    ws.Activate
    Set objTable = ActiveSheet.PivotTableWizard
    objTable.RefreshTable
    
    Set objField = objTable.PivotFields("Category")
    objField.Orientation = xlRowField
    Set objField = objTable.PivotFields("Price Band")
    objField.Orientation = xlColumnField
    
    Set objField = objTable.PivotFields("A")
    objField.Orientation = xlDataField
    objField.NumberFormat = "##0"
    
End Sub
Cheers,
Ragav

Book2.xlsm