Hi,
I am trying to Run the dynamic selection Pivot tab,its reflecting a error as Invalid procedure call or argument I have bolded the code lines which reflect error .I am unable to figure out what went wrong.
Sub Macro2()
'
' Macro2 Macro
'
'
Range("N3").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"myData", Version:=6).CreatePivotTable TableDestination:= _
"[Trial.xls]Trial!R3C14", TableName:="PivotTable2", DefaultVersion:=6
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("G/L acct"), "Sum of G/L acct", xlSum
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Sum of G/L acct")
.Orientation = xlRowField
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Beganning Balance"), "Sum of Beganning Balance", _
xlSum
ActiveWindow.SmallScroll ToRight:=2
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields(" Accumulated balance"), _
"Sum of Accumulated balance", xlSum
Range("Q3").Select
End Sub
I am trying to Run the dynamic selection Pivot tab,its reflecting a error as Invalid procedure call or argument I have bolded the code lines which reflect error .I am unable to figure out what went wrong.
Sub Macro2()
'
' Macro2 Macro
'
'
Range("N3").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"myData", Version:=6).CreatePivotTable TableDestination:= _
"[Trial.xls]Trial!R3C14", TableName:="PivotTable2", DefaultVersion:=6
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("G/L acct"), "Sum of G/L acct", xlSum
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Sum of G/L acct")
.Orientation = xlRowField
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Beganning Balance"), "Sum of Beganning Balance", _
xlSum
ActiveWindow.SmallScroll ToRight:=2
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields(" Accumulated balance"), _
"Sum of Accumulated balance", xlSum
Range("Q3").Select
End Sub