View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_6_] Gary Brown[_6_] is offline
external usenet poster
 
Posts: 126
Default Passing Criteria to a Pivot Table from combo boxes

Here's a sample of some code that should put you in the right direction:
'/---------------------------------------------------------
Public Sub aa_Test()
Dim iCount As Integer, i As Integer

On Error GoTo Exit_Sub

'identify the pivot table and field name in combo box
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Name")
'get # of items in the pivotfield
iCount = .PivotItems.Count
're-set all items to visible
For i = 1 To iCount
.PivotItems(i).Visible = True
Next i
'turn off all items EXCEPT the one in the combobox
For i = 1 To iCount
If .PivotItems(i).Value < _
Worksheets("Sheet1").ComboBox1.Value Then
.PivotItems(i).Visible = False
End If
Next i

End With
Exit_Sub:
End Sub
'/---------------------------------------------------------

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Steve Muir" wrote:

Hi,

I have done something similar in the past but not quite the same as this.

I have a worksheet which has 8 different criteria I need to pivot on.

I have a front sheet with 8 combo boxes on it (for the end user to select
criteria) and need to pass these values to a pivot table, which in turn
outputs various graphs etc from the data returned by the pivot table. The
pivot table and graphs work fine but I don't know how to pass the combobox
values to the pivot table.

Any advice or pointers would be greatly appreciated.

Many thanks