rbyrne8760
New Member
- Joined
- Jul 12, 2013
- Messages
- 2
Hello,
I am creating a macro that creates several pivot tables. These tables each filter out a set of data. If the report I run the macro on, one day, has no results for one of those sets of data, the macro results in an error. The error states "Unable to set visible property of PivotItem class" in Excel 2007. When I go to debug this, I am brought to this string of information.
Can anyone help me with this? If there are no results to filter out for that day, I simply want the results box for that category to show up blank
I am creating a macro that creates several pivot tables. These tables each filter out a set of data. If the report I run the macro on, one day, has no results for one of those sets of data, the macro results in an error. The error states "Unable to set visible property of PivotItem class" in Excel 2007. When I go to debug this, I am brought to this string of information.
Code:
ActiveSheet.PivotTables("PivotTable5").PivotFields("Repair Unit").CurrentPage _
= "(All)"
'With ActiveSheet.PivotTables("PivotTable5").PivotFields("Repair Unit")
' .PivotItems("CAMERAS").Visible = False
' .PivotItems("HENKE").Visible = False
' .PivotItems("INSIDE REPAIR").Visible = False
'.PivotItems("OEM REPAIR").Visible = False
Set PF = ActiveSheet.PivotTables("PivotTable5") _
.PivotFields("Repair Unit")
PF.ClearAllFilters
With PF
For Each PI In .PivotItems
If Not (PI.Caption Like "OUTSIDE REPAIR") Then
PI.Visible = False
End If
Next PI
End With
Can anyone help me with this? If there are no results to filter out for that day, I simply want the results box for that category to show up blank
Last edited: