I'm trying to write a macro that filters a record in a pivot table. The only way i can figre to do it is to list each and every item and make their visibility false. This would be o, if the data wasn't always changing. I would need to change the macro code every time new records are added to the data. Does anyone know a code that will let me hide all the records except the one that I specify as "true"?
Sub Macro6()
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Refer")
.PivotItems("1107469").Visible = True
.PivotItems("1112416").Visible = False
.PivotItems("1115176").Visible = False
.PivotItems("1136275").Visible = False
End With
End Sub
The other part of this question is why isn't this code working to select the active cell for the filter. The EXACT same code works in other workbooks, but i get an error on this pivot table. Code is the same exact, could it be something with the way the pivot table itself is set up? It fails on the ".pivotitems" line. I made sure the active cell picked up in "REFER_Filter" is a valid record in that pivot field, so that isn't the problem.
Sub Macro8()
REFER_Filter = ActiveCell.Value
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Refer")
.PivotItems(REFER_Filter).Visible = True
End With
End Sub
Thanks,
Joe
Sub Macro6()
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Refer")
.PivotItems("1107469").Visible = True
.PivotItems("1112416").Visible = False
.PivotItems("1115176").Visible = False
.PivotItems("1136275").Visible = False
End With
End Sub
The other part of this question is why isn't this code working to select the active cell for the filter. The EXACT same code works in other workbooks, but i get an error on this pivot table. Code is the same exact, could it be something with the way the pivot table itself is set up? It fails on the ".pivotitems" line. I made sure the active cell picked up in "REFER_Filter" is a valid record in that pivot field, so that isn't the problem.
Sub Macro8()
REFER_Filter = ActiveCell.Value
With ActiveSheet.PivotTables("PivotTable7").PivotFields("Refer")
.PivotItems(REFER_Filter).Visible = True
End With
End Sub
Thanks,
Joe