Hello Alice,
Thank you very much for your help.
Although I have not used a pivot table before, it looks like this will work very well with what I need to achieve.
What I need is to specify what I want to keep i.e. "Helicopter". I guess it would be very similar not the function of 'Auto Filter'. If it is possible to have multiple criteria that would be brilliant. i.e. only show cells between certain dates..... or I am I dreaming?
I run the code from a macro.
At the moment I can't get the code to run.....do I need to define where/what the table is?
Sub PivtoHideItemsField()
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim strPF As String
Set pt = ActiveSheet.PivotTables(1)
'the VBA editor throws a message "Can't execute code in break mode" at this point.
strPF = InputBox("What Field?", "Field Name")
Set pf = pt.PivotFields(strPF)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
With pf
.AutoSort xlManual, .SourceName
For Each pi In pf.PivotItems
pi.Visible = False
Next pi
.AutoSort xlAscending, .SourceName
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
I hope to assign VBA to a button to run the code.
Thanks for your help in advance.
If it helps I can send you a copy of the sheet in question.