I have a pivot table containing the following data elements:
EAST.01.07.01
NORTH_HPAJ
SOUTH_HPAJ
WEST.01.06.1
WEST.01.06.1.2
WEST.01.09.1.2
I have 4 option buttons labeled NORTH, SOUTH, EAST, and WEST. As you can see, WEST is comprised of 3 elements, but all these elements are not useful to the user. Only WEST.01.06.1 should be seen by the user. My VBA code is not written to properly return the data. When I choose any of the option buttons, they all return the excess data from WEST. This is just a very simplified explanation, because in reality there will be dozens of unused elements that I don't want to show up. I've attached the relevant spreadsheet. Also, here is my code. I appreciate any help. Thanks and have a blessed day.
Private Sub test()
Set sh = ActiveSheet
On Error Resume Next
Application.ScreenUpdating = 0
With Sheets("DETAILS").PivotTables(1).PivotFields("Element")
.ClearAllFilters
.PivotItems("NORTH_HPAJ").Visible = sh.OptionButtons(1).Value = 1
.PivotItems("SOUTH_HPAJ").Visible = sh.OptionButtons(2).Value = 1
.PivotItems("WEST.01.06.1").Visible = sh.OptionButtons(4).Value = 1
.PivotItems("EAST.01.07.01").Visible = sh.OptionButtons(3).Value = 1
End With
Application.ScreenUpdating = 1
End Sub
Bookmarks