How to create pivot table using vba code
Sub CreatePivotTable()
Dim pc As PivotCache
Dim pt As PivotTable
Dim pf As PivotField
Set pc = ThisWorkbook.PivotCaches.Create(xlDatabase, SourceData:=Sheet1.Name & "!" & Sheet1.Range("A1").CurrentRegion.Address, Version:=xlPivotTableVersion15)
Worksheets.Add
Range("A1").Select
Set pt = pc.CreatePivotTable(TableDestination:=ActiveCell, TableName:="Emp Report")
Set pf = pt.PivotFields("Product")
pf.Orientation = xlRowField
Set pf = pt.PivotFields("Region")
pf.Orientation = xlColumnField
Set pf = pt.PivotFields("Name")
pf.Orientation = xlDataField
ActiveSheet.PivotTables("Emp Report").NullString = 0
End Sub
On this page of the site you can watch the video online How to create pivot table using vba code with a duration of hours minute second in good quality, which was uploaded by the user VBA Learning tutorials 20 May 2020, share the link with friends and acquaintances, this video has already been watched 186 times on youtube and it was liked by 4 viewers. Enjoy your viewing!