VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Hello All,
I'm trying to record a macro that inserts a pivot table from data from one worksheet onto a newly created worksheet, but I'm getting this error here...
The code in RED is the code below that it bugs on.
Can anyone help me fix this?
Thanks much!
I'm trying to record a macro that inserts a pivot table from data from one worksheet onto a newly created worksheet, but I'm getting this error here...
"runtime 5"
"Invalid procedure call or argument"
The code in RED is the code below that it bugs on.
Rich (BB code):
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Sheet2").Name = "Cht-P"
Sheets("DB-P").Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DB-P!R1C1:R6674C5", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Cht-P!R1C1", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion12
Sheets("Cht-P").Select
Cells(1, 1).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Cht-P!$A$1:$C$18")
ActiveWorkbook.ShowPivotChartActiveFields = True
ActiveChart.ChartType = xl3DColumnClustered
ActiveWorkbook.ShowPivotChartActiveFields = False
Can anyone help me fix this?
Thanks much!