473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Updating Pivot Table Page Fields based on another page field

31
I have been working with VBA for less than a year, but mostly in Access. I have come accross an issue in Excel that I want to solve programatically.

I have several pivot tables on one work sheet that feed several pivot charts.

I am looking for code that will update each pivot table based on the page I select from the first pivot table on that worksheet.

Basically, once I update the first pivot table, I need each of the remaining pivots to get the same update.

If I can get this to work, it will save me a ton of time.

I appreciate any help you give me.

A
Jun 2 '09 #1
3 6401
NeoPa
32,556 Expert Mod 16PB
I've not worked with these objects before but I've done some VBA. If you'd like to post your working spreadsheet I'll see what I can do for you.
Jun 4 '09 #2
apank
31
Thanks NeoPa. But I found some code on line. I forgot the link, but here is the code that worked for me.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     Dim pt As PivotTable
  3.  
  4.     If Not Intersect(Target(1, 1), Range("Branchcode")) Is Nothing Then
  5.         Set pt = Sheet9.PivotTables(1)
  6.         pt.RefreshTable
  7.     With pt
  8.         .RefreshTable
  9.         .PivotFields("Office Code").CurrentPage = Range("Branchcode").Text
  10.  
  11.         End With
  12.  
  13.     End If
  14.  
  15. End Sub
I simply changed the pivot table # to have it update 9 different pivot tables and subsequent charts.

Thank you for stepping up to help though.
Jun 5 '09 #3
NeoPa
32,556 Expert Mod 16PB
Ah. Well done.

With a little tweaking (& tidying) I think we can handle the 9 pivot tables (assuming they're in the one worksheet - Sheet9 from your code). Try this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2.     Dim intX As Integer
  3.  
  4.     If Not Intersect(Target(1, 1), Range("Branchcode")) Is Nothing Then
  5.         For intX = 1 To 9
  6.             With Sheet9.PivotTables(intX)
  7.                 Call .RefreshTable
  8.                 .PivotFields("Office Code").CurrentPage = Range("Branchcode").Text
  9.             End With
  10.         Next intX
  11.     End If
  12. End Sub
Jun 5 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
5
by: Raffi | last post by:
Hi folks, I'm new to JavaScript and need some help. I have a form with a select field. Depending on what is selected in this field, I want to display or not display another select field. For...
2
by: Rob | last post by:
I'm just getting around to using pivot tables and charts. I find the Pivot table interface to be INCREDIBLY frustrating. When I view a table in Design view, then choose Pivot table view, I get...
3
by: Jerry K via DotNetMonster.com | last post by:
I'm creating a pivot table using vb.net and the data is from sqlserver (desktop). I have been successful at creating the pivot table, which includes a 'date' column field. I'd like to group the...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
12
by: kabradley | last post by:
Hello, Thanks for looking at my post and hopefully having an answer or at least a suggestion to my problem. I currently work at a financial planning office that deals with many clients and accounts....
4
by: AlexNunley | last post by:
I've adopted a moderately sized (65k records) active use database (Access 2000, Windows XP). One of the most commonly used forms is whats called the RMA generation field, used to add claim...
0
by: Clare CAVS | last post by:
I have a table with a lookup column referring to another table . tblRooms has two fields, (Autonumber), and . The column I want to display is the RoomName column. If I have Bound Column = 1,...
0
by: inepu | last post by:
Is there any way to show a field in a pivot table/chart that is calculated based on other fields of the pivot? I have the following table: Date; DescriptionField_1; Slots; EmptySlots I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.