Public Sub ChangeDataSource(ByVal newArea As Area)
An Area object representing the new data source in the same workbook.
Area newArea = worksheet.CreateArea("A1:C7");
pivotTable.ChangeDataSource(newArea);
Dim newArea As Area = worksheet.CreateArea("A1:C7")
pivotTable.ChangeDataSource(newArea)
If a null reference is passed in as parameter instead of a valid Area object, if the new data source is not in the same workbook, or
if not all the cells in the first row of the new area contain a value for the column name, then an exception of type ArgumentException will be thrown.