Using VBA I have been able to:
- create the Pivot table
- set the Row Fields for positions 1,2, and 3
Now I am trying to filter position 2 using VBA. This field contains dates except for "Not Yet Assembled." I only want to display the count of items that have not yet been assembled. The problem is that the macro will set some of the dates to FALSE but not all. I have checked the dates using the TYPE function and they are numbers.
I have searched most the day and used the following websites as references: Row count on the Filtered data
https://www.contextures.com/xlPivot03.html
https://www.mrexcel.com/board/threads/vba-hide-everything-but-1-item-in-a-pivot-table-field.586201/
Here is the code section that is not working:
With DSheet.PivotTables("pvtSK").PivotFields("ASSEMBLY DATE")
.Orientation = xlRowField
.Position = 2
End With
For Each Pi In PTable.PivotFields("ASSEMBLY DATE").PivotItems
If Pi <> "NOT YET ASSEMBLED" Then Pi.Visible = False
Next Pi