![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 33
|
Hello again,
I just had a follow up to my previous post: What I am trying to do is simply "refresh" an existing Pivot Table to reflect the source data range (ie, A2:G3002) at that moment. The source data range will fluctuate from week-to-week (ie, 3099 rows the next week). So I just want the pivot table to remain current, without having to manually go back into the "Pivot Table Wizard" and specify a new range each time (A2:G3099 this time). Does anyone have macro/VBA code which can dynamically update an existing pivot table such as this? Any assistance would be greatly appreciated. Thanks, Rob (again, I know!) |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
You don't update the PivotTable's data range. You use a named range (e.g., Database) that is updated each time the data list is extended.
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
Assign a cell say a1 to hold the value of number of rows in your original data in the pivot table using the counta(g:g). then use concatenate to create the string ("a1: g" , a1) in a cell say a2
Then in the pivot table wizard use indirect(a2) and refresh, it works like a charm. |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
cell a2 has a range address!
|
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
I looked up my model. I have named A2 as sourcerange and using indirect(sourcerange) in step2 of pivot table wizard. It works.
|
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
Both XL97 and XL2000 will allow you to create a named range that refers to =INDIRECT(A2) and then use that named range at Step 2, but this is approach has no advantages over my original suggestions. Nothing is gained by storing a text representation in a worksheet cell and then referencing it from a named range. [ This Message was edited by: Mark W. on 2002-03-11 15:42 ] |
|
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
I first created the pivot table and then did this approach to make my table dynamic.
how do you dynamically change the named range? |
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Mar 2002
Posts: 76
|
I am using XL97 and did not encounter any problems.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|