ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Controlling Pivot Table Page-Field (https://www.excelbanter.com/excel-discussion-misc-queries/139690-controlling-pivot-table-page-field.html)

[email protected]

Controlling Pivot Table Page-Field
 
Controlling Pivot Table Page Field.

Thank you for looking at this query, I have tried the code, but there is an
error.



I have tried this code, but ran into run-time error:
"Unable to set the_Default Property of the Pivot Item class"

What I have done:
1.Cell C2: key in date (31/03/07 or 28/02/07)
2.Cell C2: use vlookup & indexmatch, it doesn't change the PivotField,
PageField.


---Taken from the community-------------------------------

Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Set pt = Worksheets("Sales Pivot").PivotTables(1)
Set pf = pt.PageFields("End-Mth")

If Target.Address = "$C$2" Then

Application.EnableEvents = False
For Each pi In pf.PivotItems
If LCase(pi.Value) = LCase(Target.Value) Then
pf.CurrentPage = pi.Value
Exit For
End If
Next pi
Application.EnableEvents = True

End If

End Sub




What I wanna do:
Cell C2: Use Reference formulas to change Pivot-PageField

Sheet 1: Data entry
Sheet 2: Central Control (this is where C2 is AND uses Vlookup & IndexMatch)
Sheet 3: Pivot Table (change according to sheet 1)



Thank you for the help.




All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com