Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Update Pivots Dynamically

I have spreadsheets that have multiple pivots tables and am looking for a
way to dynamically reset the source range. I've tried the code below (and
some variations) but always end up with 1 error or another. The other idea
to minimize the maintenance is to run as many pivots as possible off of a
master pivot (would probably help minimize File size etc also). Any
suggestions on how to approach this would be appreciated. Thanks in
advance.

Sub UpdatePivot()
Dim ObjPivot as Pivotable
Dim sSource as String

sSource = inputbox("Enter Pivot Source Range")


For each objPivot in ActiveworkBook.Sheets("Pivot").PivotTables
' I've tried the 2 line below separately, not bot in the same sub
set objPivot.Sourcedata = sSource
Set ActiveworkBook.Sheets("Pivot").PivotTables(objPivo t.Name) =
sSource

Next

End Sub

Sincerely,

Wayne Huxman



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Update Pivots Dynamically

You could change your code so you can select the source range, instead
of typing it, then use that range to get the source address:

'=====================
Sub UpdatePivotSource()
Dim ObjPivot As PivotTable
Dim rngSource As Range
Dim sSource As String
Set rngSource = Application.InputBox("Select the Pivot Source Range",
Type:=8)

sSource = "'" & rngSource.Parent.Name & "'!" &
rngSource.Address(ReferenceStyle:=xlR1C1)

For Each ObjPivot In ActiveWorkbook.Sheets("Pivot").PivotTables
ObjPivot.SourceData = sSource
ObjPivot.PivotCache.Refresh
Next
End Sub
'====================

To change the pivot cache, there's sample code he

http://www.contextures.com/xlPivot11.html

Wayne Huxman wrote:
I have spreadsheets that have multiple pivots tables and am looking for a
way to dynamically reset the source range. I've tried the code below (and
some variations) but always end up with 1 error or another. The other idea
to minimize the maintenance is to run as many pivots as possible off of a
master pivot (would probably help minimize File size etc also). Any
suggestions on how to approach this would be appreciated. Thanks in
advance.

Sub UpdatePivot()
Dim ObjPivot as Pivotable
Dim sSource as String

sSource = inputbox("Enter Pivot Source Range")


For each objPivot in ActiveworkBook.Sheets("Pivot").PivotTables
' I've tried the 2 line below separately, not bot in the same sub
set objPivot.Sourcedata = sSource
Set ActiveworkBook.Sheets("Pivot").PivotTables(objPivo t.Name) =
sSource

Next

End Sub

Sincerely,

Wayne Huxman





--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
Dynamically update label axis *format* without VBA? (03 and 07) ker_01 Charts and Charting in Excel 6 March 17th 10 11:59 PM
How do I set up formulas to update graphs dynamically [email protected] Charts and Charting in Excel 5 August 5th 08 06:56 PM
I would like to build macro's to do pivots or part of pivots Todd F.[_2_] Excel Programming 2 July 29th 05 03:59 PM
Pivots using other pivots and dynamic query problem lc Excel Programming 0 November 7th 03 03:02 PM
Enter data into a cell and dynamically update another cell Tom Ogilvy Excel Programming 0 September 13th 03 12:28 AM


All times are GMT +1. The time now is 10:14 AM.

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

About Us

"It's about Microsoft Excel"