Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create drop down box based on pivot page items? 1

Status
Not open for further replies.

searlerm

MIS
Jul 28, 2001
22
0
0
GB
I am using a pivot table with Page items being dates of transactions and want to be able to use a Combo-Box on another sheet to select the required date. I have looked at Getpivotdata etc and various basic VB codes but am a bit lost. Can anyone advise please?
 
Use the PivotItems method to return the PivotItems collection. The following example creates an enumerated list of field names and the items contained in those fields for the first PivotTable report on Sheet4.





Worksheets("sheet4").Activate
With Worksheets("sheet3").PivotTables(1)
c = 1
For i = 1 To .PivotFields.Count
r = 1
Cells(r, c) = .PivotFields(i).Name
r = r + 1
For x = 1 To .PivotFields(i).PivotItems.Count
Cells(r, c) = .PivotFields(i).PivotItems(x).Name
r = r + 1
Next
c = c + 1
Next
End With


Use PivotItems(index), where index is the item index number or name, to return a single PivotItem object. The following example hides all entries in the first PivotTable report on Sheet3 that contain "1998" in the Year field.

Worksheets("sheet3").PivotTables(1) _
.PivotFields("year").PivotItems("1998").Visible = False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top