Hello ,
I am trying to create a Pivot table with VBA.
I have DATA in SHeet1.
all i want is to create a PIVOT TABLE automation with VBA.
Currently, this is the code i have :
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!C1:C8").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("LOGFILE_DESC"), "Count of LOGFILE_DESC", xlCount
With ActiveSheet.PivotTables("PivotTable2").PivotFields("LOGFILE_USER_ENTRY")
.Orientation = xlRowField
.Position = 1
End With
IT WORKS FINE TILL THE CREATION OF TABLE & LATER it gets an error.
Can anyone help me with this???
I am trying to create a Pivot table with VBA.
I have DATA in SHeet1.
all i want is to create a PIVOT TABLE automation with VBA.
Currently, this is the code i have :
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!C1:C8").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("LOGFILE_DESC"), "Count of LOGFILE_DESC", xlCount
With ActiveSheet.PivotTables("PivotTable2").PivotFields("LOGFILE_USER_ENTRY")
.Orientation = xlRowField
.Position = 1
End With
IT WORKS FINE TILL THE CREATION OF TABLE & LATER it gets an error.
Can anyone help me with this???