PDA

View Full Version : Trouble with Pivot table



Chandrasheka
10-15-2010, 06:02 AM
Hi,

Please find attached file I am facing problem in pivot table please run the code and see the result, I am not getting list only.

Thanks

hardeep
10-15-2010, 10:26 PM
Hi,

Please find attached file I am facing problem in pivot table please run the code and see the result, I am not getting list only.

Thanks
I am Not a Expert, Change the Colored Line

Sub pivot_creation()
Dim pvt_che As PivotCache
Dim pvt_tbl As PivotTable

lstrw_sh1 = ThisWorkbook.Worksheets(1).Range("C" & Rows.Count).End(xlUp).Row
Set Rng = Sheet1.Range("B1" & ":" & "C" & lstrw_sh1)
Set pvt_che = ThisWorkbook.PivotCaches.Add(xlDatabase, Rng)
Set pvt_tbl = pvt_che.CreatePivotTable(Worksheets(3).Range("A1"))

ThisWorkbook.ShowPivotTableFieldList = True

With pvt_tbl.PivotFields("Name")
.Orientation = xlRowField
.Position = 1

End With

With pvt_tbl
.AddDataField pvt_tbl.PivotFields("Cat Name"), "CatName", xlCount
End With

ThisWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False
Set pvt_che = Nothing
Set pvt_tbl = Nothing

End Sub

Chandrasheka
10-19-2010, 01:29 AM
Hi,

Thank you its working fine.

Regards,

Chandra Shekar