I've recorded a macro to create a pivottable and then tried to amend it to pick up a defined range
I'm getting run time error 5 when I try to run it
the code as far as the error is as below
Also can I change the TableName to say "SumPivot"?
N.b. I'm in Office10
Thanks
I'm getting run time error 5 when I try to run it
the code as far as the error is as below
Dim MyRange As Range
Range("A5").Select
Selection.CurrentRegion.Select
Set MyRange = Selection
Range("A1").Select
MyRange.Select
Sheets.Add.Name = "PIVOT OF"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
MyRange, Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="PIVOT OF!R3C1", TableName:="PivotTable4" _
, DefaultVersion:=xlPivotTableVersion14
Advice on what's causing the error would be appreciated.Range("A5").Select
Selection.CurrentRegion.Select
Set MyRange = Selection
Range("A1").Select
MyRange.Select
Sheets.Add.Name = "PIVOT OF"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
MyRange, Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="PIVOT OF!R3C1", TableName:="PivotTable4" _
, DefaultVersion:=xlPivotTableVersion14
Also can I change the TableName to say "SumPivot"?
N.b. I'm in Office10
Thanks