View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] a.barker728@btinternet.com is offline
external usenet poster
 
Posts: 4
Default Macro to update pivot table data range

Hi all,
I am trying to create Macro in excel 2010 which will change the data range for a pivot table if have added extra datainto the source data worksheet. This is the macro belowbut it returns a runtime error 5 "Invalid procedure Call) error:

Sub ChangePivotTableDataRange()

ActiveSheet.PivotTables("PivotTable1").ChangePivot Cache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Worksheets("Sales").Range("A5").Curren tRegion.Address _
, Version:=xlPivotTableVersion14)

End Sub

Any help on this would be greatly appreciated.

Taffy