Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using VBA to change Pivot Table data source

I have a workbook with 20 Pivot Tables that I need to update the last row
referenced by the data set for the Pivot Table via VBA. I have the last row
number by using:

NumberOfEntries = _
Worksheets("Raw_Data").Cells(Rows.Count, "A").End(xlUp).Row

.... (more code) and after loading updated data I want to programmatically
update the data set used to include all rows in the worksheet. Problem is
that Excel hard codes the path to the file name in the SourceData:= field:

Sheets("Usage by PMT PT").Select
ActiveSheet.PivotTables("PivotTable15").ChangePivo tCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, _
SourceData:="C:\[MyWorkbook.xlsm]Organization!R5C1:R860C17", _
Version:=xlPivotTableVersion12)

I've tried using ActiveWorkbook.Path and building a path string to where
ever the workbook might be but that doesn't seem to work. All I need to do
is update the total number of rows involved in the data set as the columns
don't change.

Any ideas on how to do this? I searched the discussion group already and
found nothing pertaining to this type of problem. Also, I am using 2007 with
latest service packs installed.

Thanks,

Bryan44
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table change data source mcarter Excel Discussion (Misc queries) 0 September 14th 09 06:14 PM
Can't change Pivot Table data source AABob Excel Worksheet Functions 1 January 30th 09 07:07 PM
Change pivot table source data via macro Tim879 Excel Discussion (Misc queries) 2 June 1st 07 01:31 PM
change data source of pivot table JohnH Excel Discussion (Misc queries) 9 September 15th 06 12:52 AM
Change the range of a pivot table data source Tony White[_2_] Excel Programming 3 July 11th 05 07:46 PM


All times are GMT +1. The time now is 08:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"