Hi There,
i am trying to create a pivot table with multiples ranges, but I am getting the following error when I use a variable for the SourceData.
Run-Time error '1004'
connot open Pivot Table source file 'Array(Array("Jan.xls'.
If I use the range instead of the variable it work.
could somebody help please.
SheetsRanges = "Array(Array(" & Chr(34) & "Jan!R4 C19:R6C28" & Chr(34) & ", " & Chr(34) & "Item1" & Chr(34) & "))"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlConsolidation, SourceData:=SheetsRanges).CreatePivotTable TableDestination:=Range("R12"), TableName:="PivotTable2"
i am trying to create a pivot table with multiples ranges, but I am getting the following error when I use a variable for the SourceData.
Run-Time error '1004'
connot open Pivot Table source file 'Array(Array("Jan.xls'.
If I use the range instead of the variable it work.
could somebody help please.
SheetsRanges = "Array(Array(" & Chr(34) & "Jan!R4 C19:R6C28" & Chr(34) & ", " & Chr(34) & "Item1" & Chr(34) & "))"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlConsolidation, SourceData:=SheetsRanges).CreatePivotTable TableDestination:=Range("R12"), TableName:="PivotTable2"