特定の値のみを抽出し、
そのほかの値は非表示にする。
なお、myVal変数を配列にして、
二重ループにすると、
複数の値が抽出できる。
<サンプル>
Sub B_特定の値のみ選択する()
Application.ScreenUpdating = False
Dim PT As String
Dim PF As String
Dim myVal As Variant
PT = "ピボットテーブル"
PF = "年月日"
myVal = "2009/1/1"
With ActiveSheet.PivotTables(PT).PivotFields(PF)
'非表示の時は実行しない
If .Orientation = 0 Then
Exit Sub
End If
'選択開始
On Error Resume Next
i = 1
Do While i < .PivotItems.Count + 1
If .PivotItems(i).Value <> myVal Then
.PivotItems(i).Visible = False
ElseIf .PivotItems(i).Value = myVal Then
.PivotItems(i).Visible = True
End If
i = i + 1
Loop
On Error GoTo 0
End With
Application.ScreenUpdating = True
End Sub