owentmoore
Technical User
Hi all,
I've taken the code below from thread707-694278 in which Skip describes how to select a pivot item based on a value in a cell.
The code works fine when the value in the cell i'm selecting is a text value. However when I try enter a number, the code fails as the value is not being read, the code executing deselects all pivot items which is not allowed as there must be at least one pivot item selected.
Is there anyhing can be done to change this?
Thanks
Owen
I've taken the code below from thread707-694278 in which Skip describes how to select a pivot item based on a value in a cell.
The code works fine when the value in the cell i'm selecting is a text value. However when I try enter a number, the code fails as the value is not being read, the code executing deselects all pivot items which is not allowed as there must be at least one pivot item selected.
Is there anyhing can be done to change this?
Code:
Sub SelectRef()
For Each pit In ActiveSheet.PivotTables("PivotTable1").PivotFields("1").PivotItems
With pit
.Visible = True
End With
Next
For Each pit In ActiveSheet.PivotTables("PivotTable1").PivotFields("1").PivotItems
With pit
If .Value = [TName].Value Then
.Visible = True
Else
.Visible = False
End If
End With
Next
End Sub
Thanks
Owen