Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How Do I Change Two Pivot Table Page Selections with VBA Code

Hello,

I need to be able to select an item from two data validation dropdowns in
Sheet1 and have the pivot table in Sheet2 show those selections in the
corresponding Page fields.

For example, on Sheet1, my first dropdown selection in cell A1 may be
"Texas"; my second dropdown selection in cell A2 may be Fritos. Once I make
these selections, I need my Pivot Table on Sheet2 to reflect these selections.

Thank you in advance for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default How Do I Change Two Pivot Table Page Selections with VBA Code

search this news group - there's been several similar questions.

Use the sheet's Change event. Right click the sheet tab and hit View Code
I've my dropdown on sheet1, cell D1 and my pivot is the only pt on sheet2
my validation changes the region field...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' check if PT region ...
If Target.Address = Range("D1").Address Then
selectPivotRegion Target.Value
Exit Sub
End If
End Sub

Sub selectPivotRegion(sRegion As String)
Dim pt As PivotTable
Dim pi As PivotItem
Set pt = Worksheets("Sheet2").PivotTables(1)
With pt.PivotFields("Region")
.PivotItems(sRegion).Visible = True
For Each pi In .PivotItems
pi.Visible = pi.Name = sRegion
Next
End With
End Sub

"dmarsh" wrote in message
...
Hello,

I need to be able to select an item from two data validation dropdowns in
Sheet1 and have the pivot table in Sheet2 show those selections in the
corresponding Page fields.

For example, on Sheet1, my first dropdown selection in cell A1 may be
"Texas"; my second dropdown selection in cell A2 may be Fritos. Once I
make
these selections, I need my Pivot Table on Sheet2 to reflect these
selections.

Thank you in advance for your help!


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 page field help Opal Excel Programming 23 March 16th 09 07:07 PM
Pivot Table Page Change Code PFLY Excel Discussion (Misc queries) 1 May 16th 08 12:42 AM
Change Page Field in a Pivot Table and Print Chart + Data Philip J Smith Excel Programming 2 February 19th 07 04:13 PM
Pivot Table Page Area selections in a macro norrislaketn Excel Programming 4 March 29th 06 08:40 PM
VBA Code for a pivot table to open database and to reference table current page Pete Straman Straman via OfficeKB.com Excel Programming 0 February 21st 05 03:57 AM


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