View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bradley Searle[_2_] Bradley Searle[_2_] is offline
external usenet poster
 
Posts: 5
Default Pivot Table - Filtering on a user defined field

Hi,

I have a VBA form in excel that allows users to select which field in a
Pivot Table to display. The selection that the user makes is a field called
'Select_Report'.

My code (below) then allows the Pivot Table to filter on a Pivotfield called
'Alias' and whatever field the user selected in 'Select_Report' - this works
fine:

ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array( _
Select_Report, "Alias")

Problem - I need to be able to sort the values in the resulting
'Select_Report' field but this does not seem to work - I've tried adding this
line to achieve this:

With ActiveSheet.PivotTables("PivotTable1").PivotFields (Select_Report)
.PivotItems("FALSE").Visible = False
End With

I get an error message saying: "Run time error 1004 - Unable to get the
Pivotfields property of the PivotTable class"

I think the problem is that it doesn't recgonise 'Select_Report' as a
PivotField (even though it's value is still set to whatever the user
selected, which is a valid field in my Pivot Table)!

I really need a way of sorting the 'Select_Report' field (it will only ever
contain TRUE or FALSE).

Please help if you can - much much appreciated. Brad