I did recorded some macros in excel and it was working perfectly till I did record a macro to creating a pivot table but after that I was facing "Run time error '5' invalid procedure call or argument" when I run this macro ! I tried to change the extension of the file to .xlsm but didn't work !!
Im not very expert in VB
the following is the code
Sub pivot()
'
' pivot Macro
'
'
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"dynamictable", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="All Wanting!R10C11", TableName:="PivotTable6", _
DefaultVersion:=xlPivotTableVersion14
Sheets("All Wanting").Select
Cells(10, 11).Select
With ActiveSheet.PivotTables("PivotTable6").PivotFields("Date")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
"PivotTable6").PivotFields("Date"), "Count of Date", xlCount
With ActiveSheet.PivotTables("PivotTable6").PivotFields("Type")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable6").AddDataField ActiveSheet.PivotTables( _
"PivotTable6").PivotFields("Date"), "Count of Date2", xlCount
With ActiveSheet.PivotTables("PivotTable6").PivotFields("Count of Date2")
.Caption = "Sum of Date2"
.Function = xlSum
End With
Range("K8").Select
End Sub
when i do debug I see the error at the first 4 lines !
any idea ?!