Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pivot Table - change page field help | Excel Programming | |||
Pivot Table Page Change Code | Excel Discussion (Misc queries) | |||
Change Page Field in a Pivot Table and Print Chart + Data | Excel Programming | |||
Pivot Table Page Area selections in a macro | Excel Programming | |||
VBA Code for a pivot table to open database and to reference table current page | Excel Programming |