Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default Help with function VBA existing code.

Hello,

I have 2 pivot tables on the same worksheet. The WCtr field is a user select
field so when a WCtr in pivottable1 choice is selected, I want to automate
the same selection in other pivotable2.
I got the following code, but it didn't update pivot2 when pivot1 is
filtered. Please help with the code. Thanks

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
'
' Macro created 5/18/2009 by ge295c
'
Dim source As PivotTable
Dim text As String

'check which table changed, we'll make the same change to the other
If Target.Name = "PivotTable1" Then
Set source = PivotTables("PivotTable2")
Else
Set source = PivotTables("PivotTable1")
End If

Application.EnableEvents = False

text = Target.PivotFields("WCtr").CurrentPage
source.PivotFields("WCtr").CurrentPage = text

Application.EnableEvents = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Help with function VBA existing code.

Have a look he
http://www.datapigtechnologies.com/f...s/pivot10.html

"Cam" wrote:

Hello,

I have 2 pivot tables on the same worksheet. The WCtr field is a user select
field so when a WCtr in pivottable1 choice is selected, I want to automate
the same selection in other pivotable2.
I got the following code, but it didn't update pivot2 when pivot1 is
filtered. Please help with the code. Thanks

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
'
' Macro created 5/18/2009 by ge295c
'
Dim source As PivotTable
Dim text As String

'check which table changed, we'll make the same change to the other
If Target.Name = "PivotTable1" Then
Set source = PivotTables("PivotTable2")
Else
Set source = PivotTables("PivotTable1")
End If

Application.EnableEvents = False

text = Target.PivotFields("WCtr").CurrentPage
source.PivotFields("WCtr").CurrentPage = text

Application.EnableEvents = True

End Sub

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
Really Help with existing VBA code... Cam Excel Programming 4 August 19th 08 05:59 PM
Really need help with existing code. Cam Excel Discussion (Misc queries) 0 August 12th 08 07:14 PM
Modify existing code to dynamic code Ixtreme Excel Programming 5 August 31st 07 11:42 AM
Help with existing code ploddinggaltn Excel Discussion (Misc queries) 1 November 27th 06 09:46 PM
Alter existing code gav meredith Excel Programming 5 April 20th 04 09:03 AM


All times are GMT +1. The time now is 08:26 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"